String String operators in js is + in php is a string concatenation of
Boolean true和false
|| &&
- || operation is not encountered a 0 number is terminated, and returns this number ( or )
- && operation is first encountered 0 number is terminated, and returns 0 if no 0 has been down operations, and returns the last number ( and )
- || and && mixing operation
- First, determine who has priority &&> ||
- Analyzing then the above two sentences
Int shaping 3-30
Float Float 2.3 -2.1
See the data type of the variable js typeof php in use var_dump () Variable See data type
Null Undefined
Difference between the two
Null null object such as find elements of the parent node
Undefined declared but not defined in a variable in the object properties
Array array
- Use array to create an array of methods can be abbreviated []
- Using the count () method to get the array length
- Use for loop through the array
Above the array index is an ordered number 0123 ***
Associative array specified index
$arrs=array("a1"=>"12","b1"=>56,"c1"=>89);
echo $ arrs [a1];
Front key which is the value
Use foreach as to traverse an associative array
foreach($arrs as $key => $value){
// echo $key."<br/>";
echo $value."<br/>";
}
constant
Php using DEFINE () method defines constants
Define(string,mixed,boolean)
String The first parameter is a string type can not bring $
Mixed second parameter is any type
boolean third parameter is a Boolean type is case sensitive
String method is simple comb
- strlen () Returns a string length
- strpos()
Operation
- Four operations returns the calculation result
- Comparison operator returns true and false
- === == == is a comparison operator 12 is == "12 is" == ture only the comparison value is not compared type === i.e. the comparison value is also more types. Mainly used in the determination
- The logical operators || && !
|| encounter is not a 0 count is terminated, and returns this number
&& met for the first 0 of the number of terminated , and returns 0, if not 0 has been down operations , and returns the last number
- Increment decrement a ++ ++ a; a-- --a;
- Ternary operator condition ? Expression 1: Expression 2
echo $a>13?"hello":"world";
Conditional statements
If else
Switch
Remarks php pages garbled
headr("Content-Type:text/html;charset=utf-8");
Provided mime type, in response to a file format to the client.
$sex ="man";
switch($sex){
case "man": echo "This is a man";
break;
case "woman": echo "This is a woman";
break;
}
Superglobals
Not limit scope of the function can be used outside the function
$ GLOBALS all global things exist here
$ _SERVER all information services are present here
$_REQUEST
$ _POST data submitted by the client post are present here
$ _GET data submitted by the client get there here
$_COOKIE
They are $ _SESSION array
get submitted in the network address bar post request body http protocol in