Ec (2); 1. boolean value: false (0, blank, null); & nbsp; true (-1, non-0 value ); 2. The echo $ s output content is $ s; & nbsp; If & quot; contains $ s or {$ s}, then the value of the variable will be displayed. {$ S} is recommended. & Nbsp; Use & quot; script ec (2); script
1. boolean value: false (0, blank, null); true (-1, non-0 );
2. The echo ''$ s' output is $ s;
If "" contains $ s or {$ s}, the value of the variable is displayed. {$ S} is recommended.
When "" is used, if "" is used in "", it must be used for escape, for example, echo "" sss "";
3. String connection: use punctuation "." To connect strings.
4. Access characters in a string: Use curly brackets after the string to specify the offset of the expected character from scratch.
The strlen ($ str) function can obtain the string length.
$ Str [0] gets the first character of the string $ str.
Substr ('000000', 5, 1) gets a character starting with 123456 characters and the result is "6 ".
5. strval ($ s) converts the $ s value to a string, and intval ($ s) converts the $ s value to an int integer value.
Double quotation marks: "a" B "= a" B;
6. array: (array brackets, comma, =>)
Array sorting: sort ($ arr );
Definition: $ arr = array (1 => ''11'', ''foo'' => ''fffooo '', ''info'' => array (2 => 22, ''ghost'' => ''host ''));
Reference: $ arr [1] $ arr [''foo''] $ arr [''info''] [2] $ arr [''info''] [''ghost' ']
Count ($ arr) gets the number of array elements
Traverse the array: $ arr = array (1 => '000000', 2 => '000000', 3 => '000000 '');
Foreach ($ arr as $ k => $ v)
Echo "{$ k }_{ $ v}
"; // Output: 2017111 2_222 3_333
7. Object
Class foo
{
Var $ a = 's'; // class variable !!
Function init () // class function
{
Echo "Doing foo .";
Echo $ this-> a; // reference the class variable !!
}
}
$ Bar = new foo;
$ Bar-> init ();
?>
8. Variables
Isset ($ s) checks whether the variable has been set. If it is not set yet, referencing $ s will cause the php prompt: Undefined variable.
By default, values assigned between variables do not affect each other (Value assignment mode );
In the case of $ a = "a"; $ B = & $ a, the values of any variable in $ a and $ B are changed, the value of another variable also changes (Transfer address assignment mode ).
Pre-Defined variables of PHP5:
$ _ SERVER ["REMOTE_ADDR & quo