How 1.php is embedded in HTML
(1) <?php ...? > Standard style (recommended)
(2) <script language= "PHP" >......</script> long style
(3) <?....? > Short style needs to be opened in php.ini.
(4) <%....%> compatible ASP style (not supported by default)
2. Each statement in PHP ends with a semicolon. That is, a semicolon is a delimiter between PHP statements. Note: In each script, the last statement can end without a semicolon
3. Note: Mainly used to represent the role
1.//single-line comment
2. #单行注释
3./*.....*/Multi-line annotation note not nested use
4./**......*/Document Comments
4. Variables
PHP is a weakly typed language and does not have to declare the data type of the variable to PHP.
PHP automatically converts variables to the correct data type based on the value of the variable.
In a strongly typed language, we must declare (define) the type and name of the variable before using it.
Variables: The values inside are often changed
Function: To store data during program execution
Naming conventions for variables:
Variables are defined starting with the $ character
Specification of a variable name: it is composed of letters, numbers, underscores, and cannot be preceded by numbers.
Variable names are case-sensitive in PHP
Identifier naming specification:
1. Must start with a letter or underscore
2. You can then make letters, numbers, and underscores
3. Special symbols cannot appear in identifiers
4. Identifiers cannot be keywords
5 Types of variables (8 kinds)
* A total of eight basic data types in PHP
4 Types of scalar:
Integer (int), floating-point number (Float/doble), Boolean (Boolean), string
2 Types of composite:
Array, object (Objeat)
2 Special types:
Resource (Resource), empty (null)
Where: Object and resource types are reference types, others are value types
Integral type: int type
PHP's Shaping is 4 bytes (32) of
Floating point number: (no distinction between single-precision double precision, 8 bytes in the same)
Defined:
$d 1=12.5;
Boolean value: (True false false)
When converted to Boolean, the following values are considered false
A Boolean value of false itself
Integer value 0
Floating-point value 0.0
Null "" String and string "0"
An array that does not include any elements
Objects that do not include any member variables
Special type NULL
SimpleXML object generated from an XML document without any tags (tags)
Strings (String)
How strings are defined in PHP
Single quote: ' parse variable not supported
Double quotes: "" Supports variable parsing
A string is made up of a series of characters
Each of these characters equates to a maximum of one byte up to 2GB
Delimiter: <<< Note the use of Terminators
Arrays array:
Multiple values can be stored in a variable
Arrays are divided into: associative arrays and indexed arrays
Defined:
$a =array (10,20,30,40);
echo $a [0]; Output 10
PHP learning the basic grammar of the first day note--php