Header
Header ('content-type:text/html; charset= utf-8'); // set the encoding format to: Utf-8header ('location:http://www.baidu.com'); // set jump to Baidu homepage header ('refresh:3; url=http://www.xiaomi.com'); // Set page interval refresh
Data type
<?PHPHeader("Content-type:text/html;charset=utf-8");//Browser Rendering Format $num= 1;//Plastic Surgery $str= "Hello ha";//character $float= 3.1415926;//floating point $bool=true;//Boolean Echo $num; Echo"<br>"; Echo $str; Echo"<br>"; Echo $float; Echo"<br>"; Echo $bool;?>
An expression
<?PHPHeader("Content-type:text/html;charset=utf-8"); //If Judgment $num=1; if($num==1){ EchoCorrect; }Else{ EchoError; } Echo"<br>"; //Switch Expression $day= "Monday"; Switch($day){ Case"Monday":Echo"Work 1"; Break; Case"Tuesday":Echo"Work 2"; Break; default:EchoSeating; Break; } Echo"<br>"; //For Loop for($i= 0;$i<10;$i++){ Echo"For Loop".$i; Echo"<br>"; } Echo"<br>"; //While Loop while($num<10){ Echo"While Loop".$num; Echo"<br>"; $num++; } Echo"<br>"; // Break $n=1; while($n<10){ Echo"While Loop".$n; Echo"<br>"; if($n==5){ Echo"Equals 5, stops, jumps out of the loop"; Echo"<br>"; Break; } $n++; } Echo"<br>"; //Three -dimensional expression $answer=$num>0? " 1 greater than 0 ":" 1 less than 0 "; Echo $answer;?>
Array
<?PHPHeader("Content-type:text/html;charset=utf-8"); $arr=Array(1,2,3,4,5,6);//Array Echo $arr[3]; Echo"<br>"; $FOODARR=Array("Scrambled eggs with tomatoes", "shredded potatoes", "braised pork ribs", "Red chicken nuggets");//Array Echo $FOODARR[2]; Echo"<br>"; $persom=Array("Name" = "Wq", "Age" =>16, "skill" = "eat");//relational Arrays (JSON-like) Echo $persom["Name"]; Echo"<br>"; Echo $persom["Age"]; Echo"<br>"; Echo $persom["Skill"];?>
Single double quotes
<? PHP Header ("Content-type:text/html;charset=utf-8"); // double Quotes output variables (if the variable exists), single quotes do not output variables $person= "You are a good person"; Echo "$person"; Echo "<br>"; Echo ' $person '; ?>
GET
<? PHP Header ("Content-type:text/html;charset=utf-8"); Echo $_get ["UserName"];? >
POST
<? PHP Header ("Content-type:text/html;charset=utf-8"); Echo $_post ["UserName"];? >
Embedded in HTML
<! DOCTYPE html>{padding: 0; Margin: 0; } div{Width:500px; Margin:100px Auto; } ul{List-style:none; } li{float:Left ; Width:100px; Height:30px; Background-color:rgba (255,255,156,0.7); Text-align:Center; Line-height:30px; } </style>PHPEcho $_get["UserName"]; ?> </li> <li> <?PHPEcho $_get["PWD"]; ?> </li> </ul></div></body>Precautions
1, stitching string is used. Instead of +
2. When submitting a form, it is best to access it in 127.0.0.1
3, the name of the PHP file can not appear in Chinese
ajax--php basic Knowledge (II.)