Declaration and naming of 3.2.1 variables
1<?PHP2 $title= "Hello";//correct3 $title 123= "Hello";//correct4$123title= "Hello";//Error5 $_title= "Hello";//correct6[Email protected]#title= "Hello"; Error7 $url= "Hello";//we get a variable URL8 Echo $url;//Result: Hello9 unset($url);//delete a variable URLTen Echo $url;//result is empty One?>
3.2.2 variable variable and reference assignment
1 <? PHP 2 $var= "php"; 3 $php= "Hello"; 4 Echo $var; // Output result php 5 Echo $$var; // Output Result Hello 6 ?>
3.3.1 String
1<?PHP2 $title= "Hello"; 3 Echo' $title, World ';//results: $title, World4 Echo"$title, World ";//results: Hello,world5 Echo"${title},world";//results: Hello,world6 Echo"{$title},world ";//results: Hello,world7 Echo"\ $title, World";//results: $title, World8?>
Casting and application of 3.3.8 type
//convert other types to integral type<?PHP$php=100.10; Echo(int)$php;//Output Result: $php=true; Echo(int)$php;//output results: 1 $php= "123php"; Echo(int)$php;//output Result: 123 $php= "Php123"; Echo(int)$php;//output results: 0?>//other types are converted to String type<?PHP$php=100.1; Var_dump((string)$php);//Output: String (4) "100.1" $php=true; Echo(string)$php;//output results: 1?>//other types are converted to floating-point type<?PHP$php= "123.2php"; Var_dump((float)$php);//output Result: float (123.2) $php= "php123.2"; Var_dump((float)$php);//output results: (0)?>//Other types convert to Boolean<?PHP$php= "PHP"; Var_dump((BOOL)$php);//Output Result: bool (TRUE) $php=0; Var_dump((BOOL)$php);//Output Result: bool (false)?>
A definitive guide to PHP development