I. basic syntax format of PHP54 1. PHP delimiter 2. PHP annotation and syntax identifier (1). single line annotation comes from C ++ annotation in C language (2) multi-line comment ** comes from C language comment 3,
I. basic syntax format of PHP5.4
1. PHP delimiter
2. PHP comments and syntax identifiers
(1) single line comment // comments from C ++ # Comments from C language
(2) multi-line comments/**/comments from C language
3. function format
(1) return value function name ()
(2) return value function name (parameter, parameter)
(3) function name (parameter, parameter, return variable)
(4) return value function name (...) common operator // PHP5.4 usage
2. data types of PHP5.4 variables and variables
A variable starts with a dollar sign "$" and is an identifier after "$. A string can contain letters, numbers, and underscores and cannot start with a number.
Variable naming method
(1) direct connection between words
$ Titlekeyword
(2) words are connected by underscores.
$ Title_keyword
(3) uppercase letters (hump) between words)
$ TitleKeyword
PHP Data types are as follows:
(1) String: content in single quotation marks (simple quotation marks) or double quotation marks (function quotation marks)
(2) integer:-2 ^ 32 <n <2 ^ 32-1
(3) floating point character (float or double) 1.8E + 308 (1.8x10 ^ 308)
(4) boolean (boolean) true or false
(5) Array)
(6) Object)
(7) resource type (Resouce) system data resources
III. PHP5.4 system constants and custom constants
Constants cannot change data during program execution, and their scopes are global. The constant name is similar to the variable name, but it does not contain the "$" symbol. A valid constant starts with a letter or underscore. generally, constants in PHP are uppercase letters and can be divided into system constants and custom constants.
Example of system constants:
_ FILE _ default constant, indicating the PHP program FILE name and path
_ LINE _ default constant, indicating the number of lines in the PHP program
_ CLASS name
The define () function is used in PHP to define a constant. the syntax format is:
Bool define (string $ name, mixed $ value [, bool case _ $ insensitive])
Name: constant name
Value: constant value
Insensitive: specifies whether the constant name is case sensitive. If it is set to true, it is case insensitive. if it is set to false, it is case sensitive. the default value is false.
Define ("COLOR", "red"); // defines a constant COLOR with the value redecho COLOR ."
"; // Outputs the COLOR value of the constant.
Variable
$ A = "B" $ a = "123" // variable echo $ B;
Output result: 123
Double quotation marks are used to output variables in strings.
$ A = 50; // echo 'I have $ a Yuan Renminbi "; single quotes echo" I have $ a Yuan Renminbi ";
In double quotation marks, more conversion characters can be executed, such as \ n \ t \ r.
Determine data type
$a="-5";//$a=-5;var_dump($a);