Part I: Data types
(1) integer--php accepts decimal, octal, and hexadecimal integers to differentiate the various binary, octal integers preceded by 0, hexadecimal plus 0x
6-2
(2) floating point type (maximum 14 digits after PHP decimal point)
6-3
(3) Boolean type
(4) string
PHP requires quotation marks before and after strings: single and double quotation marks.
Note: 1. If you use single quotation marks to represent strings, the strings are treated as plain text.
2. When a string is represented in double quotation marks, PHP handles the string appropriately, such as parsing the variable or interpreting the ' escape character '
<1> Single Quote string: There are two escape characters: \ \ and \ ', respectively, resolved to \ and '
<2> double-quoted strings: double-quote strings support more escape characters and parse the variables. 6-5.php
\n--newline \r--carriage return \t--tab
\$--dollar sign \\--backslash character \ "--double quote
The second part constants and variables
(1) constant define (Name,value)
(2) Variable variables are assigned in two main ways: pass-through values and references. The value of the variable is subject to the most recent assignment.
(3) Scope local variables for variables: variables defined within a function
Global variables: Variables that are defined outside of all functions, scoped to the entire PHP file. A global variable is used inside the function, preceded by the global Declaration.
Third part operator
Part IV Process Control (1) Judging structure: A: Single Branch if statement:
Syntax format: if (expr)//NOTE: Do not add a semicolon after this statement
statements;//Statement executed when the condition is established
Example: <?php
$score = 80;
if ($score >=60)
{
echo "<br> qualified";
}
?>
B: Dual Branch If...else Statement 6-22
C: Multi-branch If...elseif. Else Statement 6-23
The d:switch statement switch is also a multi-branched structure, although multiple judgments can be made using the ElseIf statement, but too complex. 6-24
(2) Cyclic structure a:for cycle (used with a clear knowledge of the number of cycles)
Format: for (EXPR1;EXPR2;EXPR3)
{
Statements;}
6-25.php
B:while Cycle
6-26.php
C:do...while Cycle
The difference between do...while and while is: do. The loop body of the while loop is executed at least once.
bo=
statements;
}while (expr);
D:foreach Cycle:
Basic knowledge of PHP first