php基础复习一语法基础
在前期学废了后期必须要一步一步的追上来
1 <?php 2 3 //注释 4 // 多行注释 5 6 //输出语句 7 echo "hello","helloa"; 8 print "world"; 9 echo "1.hi</br>2.","</br>3.","</br>4.yes"; 10 print_r(); //输出数组信息 11 var_dump();//变量和类型 12 13 //变量定义 14 //int, float, bool, string 15 //弱类型语言 16 $a = 10; 17 $b = "he{$a}llo"; 18 $c = 'world'; 19 $d = <<<AA 20 hello "aa" , "bb" ,'cc', 21 <input type="text" value="aa" /> 22 AA; 23 24 /*1.双引号里面可以解析转义字符,单引号不行 25 2.双引号里面可以解析变量,单引号不行 26 3,后期学习处理也封装以后这些在双引号中套单引号就会变的司空见惯*/ 27 $e = $a.$c; //拼接字符串用的是. 28 $f = 10.05; 29 30 $f = (string)$f; //类型转换 31 32 $f = "hello"; 33 34 $aa = "cc"; 35 $cc = "dd"; 36 echo $$aa; //可变变量 经典 37 $dd = &$aa; //&取地址 38 $dd = "ee"; 39 echo $aa; 40 41 //运算符与表达式 42 $a = 10; 43 $b = 4; 44 echo $a/$b; 45 46 47 echo @$c; //错误抑制符,并不能抑制所有错误 48 49 echo $a==$b?"ok":"no"; //三目运算符 50 51 if($a==$b) 52 { 53 echo "ok"; 54 } 55 else 56 { 57 echo "no"; 58 } 59 //1.if...else... 60 //2.if...else if... 61 //3.if嵌套 62 $a = 2; 63 switch($a) 64 { 65 case 1: 66 echo "11111"; 67 break; 68 case 2: 69 echo "222222"; 70 break; 71 case 3: 72 echo "333333"; 73 break; 74 default: 75 echo "444"; 76 break; 77 } 78 79 //1.for 80 for($i=0;$i<10;$i++) 81 { 82 echo $i."<br>"; 83 } 84 //2.while 85 //3.do...while 86 87 88 89 90 91 echo $e; 92 93 var_dump($f); 94 95 ?>