The string type can be defined in three ways: single-quote, double-quote, and Heredoc-structured.
"" Can contain "" "Can contain" "" must be escaped when "" "
When a variable is enclosed in double quotes, the variable is concatenated with the contents of the double quotation marks;< double quotes as variables >
When a variable is included in a single quotation mark, the variable is exported as a string.
What happens when my string is long?
We can solve this problem by using the Heredoc structure form, first using the delimiter to represent the string (<<<),
Then, after "<<<", provide an identifier for God, then the string, and finally the end string with this identifier provided.
Resources (Resource): resources are created and used by specialized functions, such as open files, data connections, and graphical canvases. We can manipulate resources (create, use, and release). Any resources should be released in a timely manner when they are not needed. If we forget to release the resources, the system automatically enables the garbage collection mechanism to reclaim the resources after the page has been executed to avoid the memory being exhausted.
Examples are as follows:
<?php$file=fopen ("F.txt", "R"); Open file $con=mysql_connect ("localhost", "root", "root"); Connection Database $img=imagecreate (100,100);//Graphics Canvas?>
Read the file
$file _handle = fopen ("/data/webroot/resource/php/f.txt", "R");
Null (NULL): null is a null type, is not case sensitive, the null type has only one value, indicating that a variable has no value, when it is assigned to NULL, or has not yet been assigned, or is unset (), the variables are considered NULL in three cases.
Define ("PI", 3.14)
System constants are constants that PHP has already defined, and we can use them directly, and common system constants are:
(1) __file__:p hp program file name. It can help us get the current file in the physical location of the server.
(2) __line__:P HP program file line number. It can tell us the current code in the first few lines.
(3) Php_version: The version number of the current parser. It can tell us the current PHP parser version number, we can know in advance whether our PHP code can be parsed by the PHP parser.
(4) Php_os: Executes the current PHP version of the operating system name. It can tell us the name of the operating system used by the server, and we can optimize our code based on the operating system.
If the constants are repeatedly defined, the PHP parser will issue a "Constant XXX already defined" warning to remind us that the constant has been defined. So how do we determine if a constant is defined when team development, or the amount of code is great?
The defined () function helps us to determine whether a constant has been defined and its syntax is:
bool Defined (string constants_name)
It only has the parameter constant_name, refers to gets the name of the constant, returns the Boolean type True if present, otherwise returns the Boolean type false; (Note: bool means the return value type of the function is a Boolean type)
PHP notes 2016/7/5