Constants and Data Types
PHP eight kinds of data types
Four scalar types
String (string), boolean (boolean), floating point (float / double), integer (integer)
Two compound types
Array (array), objects (object)
Two special types
Resources (resource) null
Define how PHP strings and their difference?
Defined manner: single quotes and double quotes heredoc newdoc
Difference: efficiency than single quotes double quotes
apostrophe
Single quote can not resolve the variable
Single quote escape character can not be resolved, it can be resolved from a single quote and backslash
Variable and can be used to point between the variables and strings, strings and string ( . ) Is connected
Double quotes
Double quotes may be parsed variables, which can use special characters and contain {}
Double quotes could not be resolved escape character
May also be used dot ( . ) Are connected
heredoc similar double quotes
newdoc similar single quotes
Both are used to process large text
type of data
Three database types (scalar, composite, special)
Float type: not available for comparison operation
Seven cases of false
Plastic 0, 0.0 floating point, boolean false, an empty string, 0 string, an empty array, null
Super global array
$GLOBALS、$_GET、$_POST、$_REQUEST、$_SESSION、$_COOKIE、$_SERVER、$_FILES
$_ENV
Memory Key
$ _SERVER [ 'SERVER_ADDR']; server IP address
$ _SERVER [ 'SERVER_NAME']; server name
$ _SERVER [ 'REQUEST_TIME']; request time
$ _SERVER [ 'QUERY_STRING']; request data
$ _SERVER [ 'HTTP_REFERER']; page request higher
$ _SERVER [ 'HTTP_USER_AGENT']; header
$ _SERVER [ 'REMOTE_ADDR']; Client IP
$ _SERVER [ 'REQUEST_URI']; Gets http: // value of the back localhost, including /
$ _SERVER [ 'PATH_INFO']; path information
NULL three cases
Directly assigned to Null, undefined variable, unset variables destruction
constant
Defined way: const define
const is faster and 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
Predefined Constants (system-defined)
__FILE__ return to file directory + file name
__LINE__ returns the current line number
__DIR__ return directory
__FUNCITON__ return function name
__CLASS__ return the class name
__TRAIT__ returned 5.2 New Features
__METHOD__ returns the class name with a method name
__NAMESPASE__ returns the namespace