Variable:
Variable Quantity, customizable multiple times
It must start with $.
Variables are case sensitive.
Naming rules for variables: (a combination of numbers, letters, and underscores. It cannot start with a number, be a Chinese character, or be a keyword)
Constant:
(Constant used for database connection)
Key word for defining constants ()
Define ("Get name", replace value)
Define a constant. when defining a constant, determine its value.
A constant can be defined only once.
Naming rules for constants: It is recommended that constants be separated by multiple words in uppercase; constants must be case sensitive; constants do not use the $ symbol; constant naming rules (composed of digits, letters, and ). However, it cannot start with a number or be named in Chinese. It cannot start with a keyword.
Example: $ A = "ABC ";
Define ("name", $ );
There are two naming methods for constants, and the other is const: const to get the name = value; (used for Object-Oriented)
PHP Arithmetic Operators
+-*/%! .
The addition in PHP is an addition operation.
Concatenate the addition in JS
Empty (): determines whether it is empty
Isset (): determines whether there is a value
Unset (): clears variable data.
Define (): defines Constants
Logical operation: | & =====! = ++ A ++ -- A -- + =-=/= * =. =
Comparison OPERATOR: <>=>=! =
Is_int (value determined) determines whether it is an integer and the returned data type is boolean.
0: false: failed; 1: true: Successful
Php_ OS // obtain the current operating system. Note that it is case sensitive and does not require parentheses.
_ Line _ magic method (case-sensitive) to get the number of lines of the current Code
_ File _ magic method to get the current file path
Dirname (_ file _) returns the directory at the upper level.
PHP file loading
Require ("file loading path") can load PHP files, JS files, HTML files
Require_once () loads the file once
Include ("file path") // you can load PHP files, JS files, and HTML files.
Include_once ("loading file path") // load the file once
What is the difference between include () and require?
Include () // loads HTML files when include () Loads files,
If there is an error in the file, it is only a warning. The code is executed as usual.
Require () // require () Load core files (
Configuration files and database connections) load files,
File error, a fatal error is prompted, and the code is not executed down
Process control statement
Original dual-branch statement:
2nd writing methods for multiple branches:
The following method is generally used for PHP and HTML interaction, which is convenient to distinguish from HTML code:
Use the following in the PHP program file:
It is recommended to interact with HTML.
Switch (Judgment value) Judgment condition:
Process control statement
All conditions are less than enough to follow the default Conditions
Example:
For () loop statement:
For example, all numbers between 1-are output cyclically.
While () loop statement:
For example, use a while loop to get all numbers from 1 to 100.
For example, do not set the odd number between 1-10 in cyclic output to 5.
Ternary operators:
The following method is generally recommended in HTML pages:
PHP functions (encapsulation functions, DB classes ):
JS declares a function name () {function body}
PHP declares a function name () {function body}
PHP function names are case insensitive
Display: Output
Naming rules for a function: A combination of numbers, letters, and underscores (_), but cannot start with a number, cannot use keywords, cannot be named in Chinese, and can be used in combination with multiple words.
When a function has a default value, you do not need to pass the parameter and value in the past when calling the function number.
If there is a default value, when I call a function, a value will overwrite the previous default value.
Multiple values of the function are separated by commas (,).
If no default value exists in the function, you must assign a value to the parameter when calling the function.
Parameters with default values are placed after those without default values.
Functions can be called anywhere
Functions and functions can be nested directly.
PHPFunctionSuper global variable
The global value of the Super global variable; $ globals ['value'] $ _ get $ _ post
/* Globals: borrow reference
$ _ Get $ _ post: obtain the value of the form from the superglobal variable (Focus)
Example:
Return:
If a function returns a value,
You must accept the function when calling the function. This variable is used to accept the result.
A function body can have only one return value, that is, only one return value;
Example:
In this example, only the first return can be obtained.
Load the 13. php file
The anonymous function calls its own PHP array key ()
Do not add the new keyword to the array in PHP
The array keywords in PHP are case-insensitive. In JS, they are case-insensitive. Array
Output:
10.29 Essays