PHP comments definition of data type variables/retrieval/conversion of output types variable, Data Type Variable
Annotation method:
1. Single line comment ://
2. Multi-line comment :/**/
Ii. Data Types
1, integer: In a 32-bit operating system, the valid range is-2147483648 ~ + 2147483648;
2. string: string variables are different from character and string variables in other programming languages. In PHP, character variables are used to define characters or strings;
3, boolean (boolean): This is the simplest type, and only two return values (true/false );
4. folat (float, also called double): The valid range of the 32-bit operating system is: 1.7E-308 ~ 1.7E + 308;
There are two composite types:
Array: the array stores multiple values in a variable;
Object: a special data type ------------------------------------------------------------------------------------------------------------------------------------
| Objects must be explicitly declared in PHP.
| First, we must declare the class of the object. A class is a structure that contains attributes and methods.
| Then we define the data type in the object class
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Two special types:
NULL (NULL type): indicates that this variable has no value. The only possible value of the NULL type is NULL;
Resource: the source is a special variable that stores a reference to an external resource. resources are created and used by dedicated functions.
3. PHP variable definition
Note:PHP is a weak type language. During definition, PHP automatically determines the type based on the type of the value stored in the variable;
1. Define the value of a as 10: $ a = 10;
2. Define the string: $ a = "abcdef"; or $ a = 'abcdef ';
Note: The difference between single double quotation marks: Double quotation marks can be translated. single quotation marks cannot be translated as strings only;
3. Special definition: $ a >>>
Define the content of a string or HTML code
A; there cannot be any leading space;
A;
4. Data Type acquisition;
Echo gettype ($ );
5. Output of Variables
1, echo (commonly used)
Echo $ a, "1234"; // multiple strings can be output simultaneously;
2, print
Print $ a; // only one string can be output;
3. Special Output Method
Print_r ([1, 2]); // you can print an array;
For example, the page displays -------- Array ([0] => 1 [1] => 2)
Var_dump ($ B); // all information about the output variable, which is generally used for debugging errors;
6. PHP data type conversion
1,Method 1:
$ A = (string) $ a; // forcibly converts the type of variable a to a string.
2. Method 2:
Settype ($ a, "string"); // forcibly convert the type of variable a to a string.
7. Variable:
$ A = "abc ";
$ Abc = "Zhang ";
Echo $;
Output result: Zhang San