The difference between post and GET request mode:
1. Different request form: Get request is to send the data angle at the end of the URL to the server, post way is in a separate message form, sent to the server in the background.
2. Different send length: Get requests maximum data quantity is theoretically unrestricted for 2k,post request, you can set its size in the configuration file.
3. Security: Because the Get-mode data is appended to the URL and sent to the server, so the security of getting is low.
4. Use the scene: get suitable for data simple, security requirements are not high when used, otherwise, use post.
Two. Declaration and use of constants:
Define (' PAI1 ', 3.1415)
const PAI2 = 3.1415;
Echo PAI1, PAI2;
Define (' ^_^ ', ' Smiley ');
This form cannot be used to output this variable with the Echo ^_^, and a function can be used to
Echo constant (' ^_^ ');
Three. Scope of variables:
Personally think there are three scopes in PHP
1. External scope, refers to the scope of a script, outside the function body, the variables declared in this area are available externally, but they cannot be used internally as functions.
2. Internal scope, refers to a script, within the scope of the function body, declared in this area of the variable, internally available, but not visible externally.
3. A Hyper global scope can be used anywhere in any script, such as within the test function of the a.php script or outside of the function, and the same applies to the B.php script.
How do you make a variable available inside an external declaration or outside of an internal declaration? --global Key
$v 1 = ' global V1 ';
Func1 ();
function Func1 () {
//echo $v 1;//undefined
global $v 1;
echo ' function inner VARs v1: ', $v 1;
}
Echo ' Below is an example of using external declarations inside a function
';
function Func2 () {
global $v 2;//comments, $V2 in global output error
$v 2 = ' function inner v2 ';
}
Func2 ();
echo $v 2;
Four. operator
% operator: the symbol for the calculated result is the same as the first operand
& Reference Operator:
$v 3 = 1;
$v 4 = & $v 3;
Unset ($v 3); Unset will be destroyed after the variable, can not access $v3
//echo $v 3;//unset visit again $v3 will give an error
And OR operator:
Same as && and function, only lower priority (lower than =)
function Func1 () {return
false;
}
$a = func1 () or Die (' func1 execution return value is False ');
$a = func1 () die (' func1 execution return value is false ');
Five. Echo and Print differences
It can be said that there is a place to use, and the other can be used. However, there is also a very important difference between the two:
In the Echo function, you can output multiple strings at the same time, whereas in the print function you can output only one string at a time. Also, the Echo function does not require parentheses, so the echo function is more like a statement than a function.
Neither Echo nor print is a function, but a language structure, so parentheses are not required. The difference between them is:
(1) Echo can output multiple strings, as follows:
Echo ' A ', ' B ', ' C ';
If you have to add parentheses, note that you write echo (' A ', ' B ', ' C '), and it is wrong to write:
Echo (' A '), (' B '), (' C ');
It does not behave like a function, so it cannot be used in the context of a function
(2) Print can only output a string, it can act like a function, for example, you can use the following:
$ret = print ' Hello world ';
All of it can be used in more complex expressions.
In addition, ECHO's efficiency is relatively fast ~
The echo command differs from the Print command
When used, echo can output multiple variables separated by commas, and print can only output one variable
There is a difference between the Echo function and the print function.
Echo () has no return value, same as echo command
Print () has a return value, success, return to 1,false, return 0. Therefore, print is slower than echo, but can be applied to more complex expressions.
Six. Differences between Isset and empty
The Isset function is used more in development to determine whether the variable exists or whether it has opened up memory.
The empty function is not only to determine whether the value is null, but also to return false when the secondary variable is not defined, that is, when memory is not developed, that is, the empty function needs to be NULL if Isset is true.
Seven. Switch can support shaping, floating-point type, string, also can support array, Boolean type, allow no default
$bol = true;
$bol = false;
$bol = [1, 2, 3];
Switch ($bol) {case
0:
Echo ' 0
';
break;
Case:
Echo ' 10
';
break;
Case-1:
Echo '-1
';
break;
case [1,2,3]://array
echo ' empty array
';
break;
Case 0:
Echo ' 0
';
break;
When the type is bool, true is output when the case value is true, false after case value is false, can run code, can be