Php (basic, variable, constant, structure statement)
|
Php beginners (basic, variables, constants, structural statements). If you need them, refer.
Basic knowledge:
?> It can be omitted that the string connector is. annotation // variable
The variable must start with $ and start with a letter or underscore (_).
It can only consist of letters, numbers, and "_" and contain Chinese characters
The case-sensitive "var_dump" function can display the data type of our Variables. it has a line feed. when we use the "echo" command to output the Boolean type, if it is "true", "1" is output, and "false" is output nothing. when the double quotation marks contain variables, the variables are connected with the content in the double quotation marks;
When a single quotation mark contains a variable, the variable is used as a string to output a long string: a constant of the separator <+ any identifier + content + identifier
Define defines system constants
(1) _ FILE _: php program FILE name. It helps us to obtain the physical location of the current file on the server.
(2) _ LINE _: Number of PHP program files. It tells us the number of lines in the current code.
(3) PHP_VERSION: version number of the current parser. It tells us the version number of the current PHP parser. we can know in advance whether our php code can be parsed by the PHP parser.
(4) PHP_ OS: name of the operating system for executing the current PHP version. It tells us the name of the operating system used by the server. we can optimize the constant value of our code based on the operating system.
Directly use the constant name mixed constant (string constant_name); // multiple types of information are returned, and the error message bool defined (string constants_name) is returned if the variable is defined.
... = // Connect the statements with a value assignment structure
(1) only values, not subscript
Foreach (array as value ){
// Executed task
}
?>
(2) obtain both the subscript and value.
Foreach (array as subscript => value ){
// Executed task
}
?>
|
Php