The basic data types php

String String operators in js is + in php is a string concatenation of

Boolean truefalse

|| &&

  1. || operation is not encountered a 0 number is terminated, and returns this number ( or )
  2. && operation is first encountered 0 number is terminated, and returns 0 if no 0 has been down operations, and returns the last number ( and )
  3. || and && mixing operation
  4. First, determine who has priority &&> ||
  5. 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

 

  1. Use array to create an array of methods can be abbreviated []
  2. Using the count () method to get the array length
  3. 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

  1. strlen () Returns a string length
  2. strpos()

Operation

  1. Four operations returns the calculation result
  2. Comparison operator returns true and false
  3. === == == 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
  4. 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

  1. Increment decrement a ++ ++ a; a-- --a;
  2. 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

 

Guess you like

Origin www.cnblogs.com/yuanyeds/p/11357810.html