[PHP] PHP entry Chapter 1: PHP case sensitivity
1) all user-defined functions, classes, and keywords are case-insensitive.
The output is consistent as follows:
Echo "hello world"
Echo "hello world"
EcHo "hello world"
2) user-defined variables, Case Sensitive
Only the first line outputs the correct color as follows
";echo "My house is " . $COLOR . "
";echo "My boat is " . $coLOR . "
";?>
2. global keyword
1) use the global keyword before the variables in the function to access the global variables.
2) in PHP, all GLOBAL variables are stored in the $ GLOBAL [index] array, the subscript stores all GLOBAL variables, and the subscript contains the variable name, this array can also be accessed in the function and can be used to directly update global variables.
3. static keywords
After the function is executed, local variables are deleted. sometimes static keywords are used to make the variables in the function memory.
IV. basic output method
Differences between echo and print:
Echo-can output more than one string
Print-only one string can be output and 1 is always returned.
Tip: echo is a little faster than print because it does not return any value.
";print "Study PHP at $txt2";print "My car is a {$cars[0]}";?>
5. string and integer
1) a string is a character sequence, such as "Hello world! ".
A string can be any text in quotation marks. You can use single or double quotation marks:
2) integer
PHP var_dump () returns the data type and value of the variable.
"; $ X =-345; // negative var_dump ($ x); echo"
"; $ X = 0x8C; // hexadecimal number var_dump ($ x); echo"
"; $ X = 047; // eight-digit var_dump ($ x);?>
Result:
int(5985) int(-345) int(140) int(39)
VI. array
$cars=array("Volvo","BMW","SAAB");var_dump($cars);
Result:
Array (3) {[0] => string (5) "Volvo" [1] => string (3) "BMW" [2] => string (4) "SAAB "}
7. NULL value
NULL indicates that the variable has no value. NULL is the only possible value of the data type NULL. NULL indicates whether the variable is NULL. you can set the value to NULL to empty the variable.