Single-line Comment
/* * * Multi-line Comment
Output statement
1. Output string
print "Hello"; Only one string can be printed
echo "World"; You can print multiple strings at the same time. (a lot of use)
2. Output type (programmer test)
var_dump("AA"); You can also add variables
3. Output array
Print_r();
Weakly typed languages
You do not need to specify a type, all variables need to add $ sign
(string)$a to convert variable A to a string
settype($a, "string"); The variable A is converted to a string, and the return value is a Boolean value.
Defining strings
1. Double quotes:
$a = "Zhang San";
2. Single quotes:
$a = ' Zhang San ';
Attention:
A. The escape character can be parsed inside a double quotation mark.
$s = "Hello \" world;
Output
B. Double quotes can parse variables.
$s = "Hello {$a} world";
Output
Escape character: \ n for line break, \ r for carriage return, \ t tab, \ ", \ ', \ \
3.
$s 2=<<<A"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >A; Var_dump ($s 2);
Output Result:
Global variables
Var_dump ($GLOBALS);
Output Result:
Variable variable
$a = "Hello"; $hello = "Zhang San"; Echo $$a;
isset($a); determine whether a $ A is defined
var_dump(isset($a)); Output result Bollinger type
unset($a); Clear variables
Empty ($a); Determine if $ A is empty
0, empty string, NULL, False
& Address
$a = ten; $b = &$a; Echo $b;
Output 10
PHP Basic Syntax