Php manual reading notes (1) 1. using agereference | BasicSyntax ?? End mark at the end of the PHP file (? & Gt;) it is best to omit it to prevent unnecessary spaces and carriage return characters from being added to the end of the file ?? Can I use/**/, //, # comment? 2. type ?? Php manual reading notes (1)
1. Language Reference | Basic Syntax
? ? End mark at the end of the PHP file (?>) It is best to omit it to prevent unnecessary spaces and carriage returns from being added to the end of the file.
? ? You can use/**/, //, # annotations.
?
2. type
? ? Four scalar types are supported: boolean, integer, float (same as double), string
? ? Two structures are supported: array and object.
? ? Three special types are supported: resource, NULL, and callable.
?
? ? You do not need to set the type. during The runtime, PHP can be derived based on the context.
?
<%php$a_bool = TRUE;$a_str = "Str";$a_str2 = 'Str';$an_int = 12;echo get_type($a_bool);if (is_int($an_int)) { echo "int";}
?
? ? Boolean: TRUE/FALSE, (bool), empty array is also FALSE
? ? Integer: Similar to C
? ? Float: Similar to C
? ? String: single quotation marks, double quotation marks (variable extensible), variables in heredoc, nowdoc, and heredoc are expanded. variables in nowdoc are not expanded. heredoc is <
? ? Array: an ordered map, which can be used as an array, a linked list, or a hash table. Create With array (), where key => value can be separated by commas.
? ? ? ? ? ? ? ? The key can be an integer or a string. if the content in the string is an integer, it will be converted to an integer; float can be converted to an integer, boolean can be converted to an integer, and value can be any value.
? ? ? ? ? ? ? ? After php5.4, the array () structure can be replaced with [].
? ? ? ? ? ? ? ? Php array keys can have both integers and strings, because php does not distinguish between index arrays and associated arrays.
? ? ? ? ? ? ? ? "Key =>" can be omitted. the preceding largest integer key + 1 is used, and the key starts from 0.
? ? ? ? ? ? ? ? When assigning values to array members, the key can also be omitted: $ arr [] = 24; this is also the maximum integer key + 1
? ? ? ? ? ? ? Unset
? ? ? ? ? ? ? Foreach loop: foreach ($ arr as $ item) {$ item ...}
? ? Object: A class instance created through the new classname. Class can have function xxx () defined method, object-> xxx () access method.
?
3. variables
? ? Starts with $ and is case sensitive.
?
4. constants
? ? Define ("name", "value ");
? ? Const HELLO = "hello ";
?