php interview topics --- 2 test sites constants and data types

php interview topics --- 2 test sites constants and data types

A summary

Sentence summary:

If the variable is null and variable evaluates to false requires careful attention to the next

 

1, PHP string method uses three definitions of what can and what their differences are?

Single quotation marks: not resolve the variable and some of the escape character, but more efficient
Double quotes: analytical variables and the escape character
heredoc and newdoc: to handle large text: Heredoc similar double quotation marks; newdoc similar single quote

 

Single quotes
single quotes more efficient
single quotation variables can not be resolved
single quote escape character can not be resolved, only resolve single quotes and backslash
variable and, between the variables and strings, strings and string can be. Connected


double quotes
double quotes may be parsed variables, which can use special characters and {} contains
double quotation marks could not be resolved escape character
may be used. to connect

Heredoc similar double quotes
Newdoc similar single quotes

 

2, php in three data types?

Scalar:
Composite: array: the array; object: Object Type
Special: resource: resources; null: null

 

3, $ a = 0.1; $ b = 0.7; if ($ a + $ b == 0.8) {} determination result is true or false, and why?

false: 0.1 + 0.7 as calculated from the result of the computer may be 0.799999999; not use floating point type is equal to the comparison operation
Decimals will turn Binary loss

 

4, FALSE seven cases?

0, 0.0, '', '0', false, array (), NULL; integer 0, 0.0 floating point, boolean false, an empty string, the string 0, empty array, NULL

 

5, php super global array What?

$GLOBALS、$_GET、$_POST、$_REQUEST、$_SESSION、$_COOKIE、$_SERVER、$_FILES、$_ENV

 

6, $ _SERVER super global variables in common?

$_SERVER[ 'SERVER_ADDR']
$_SERVER[ 'QUERY_STRING']
$_SERVER[ 'HTTP_REFERER']
$_SERVER[ 'REMOTE_ADDR']

 

 

$_SERVER[ 'SERVER_ADDR']
$_SERVER[ 'SERVER_NAME']
$_SERVER['REQUEST_TIME']
$_SERVER[ 'QUERY_STRING']
$_SERVER[ 'HTTP_REFERER']
$_SERVER['HTTP_USER_AGENT']
$_SERVER[ 'REMOTE_ADDR']
$_SERVER['REQUEST_URI']
$_SERVER[ 'PATH_INFO']

 

7, phpNULL three cases?

Direct assignment to NULL
Undefined variables
Unset variables destruction

 

8, constant definitions and define the characteristics and differences of const?

const faster, language structure, define a function
It can not be used to define classes define constants, const can
Constants, once defined, can not be modified, can not be deleted

 

9, php commonly used system constants?

(1) __ FILE__: php file name. It can help us to get the physical location of the current file server.
(2) __ LINE__: the number of files row PHP. It can tell us, the first few lines in the current code.

__FILE__、__LINE__、__DIR__、__FUNCTION__、__CLASS__、__TRAIT__、__METHOD__、__NAMESPACE__

 

10, written in PHP display client IP and server IP code?

$_SERVER[ 'REMOTE_ADDR']和$_SERVER[ 'SERVER_ADDR']

 

 

11, __ FILE__ What does it mean?

Get the current physical location of the server's file

 

 

 

Second, content in summary

 

 

 

 

Reproduced in: https: //www.cnblogs.com/Renyi-Fan/p/11059591.html

Guess you like

Origin blog.csdn.net/weixin_34185364/article/details/93572342