php+apache+mysql大法好.
被网络对抗作业逼疯(吐血
帮助手册
声明变量
1 2 3 4 5 6 7 8 9 10 
  | <?php $var = 100; $var2 = 200; const var3 = 300; echo $var+$var2; echo '<br>'; echo var3; define('var4', 9000); echo var4; ?> 
  | 
 
声明函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
  | <?php function test($name){     echo 'hello php<br>';     echo 'hello tbl<br>';     echo 'hello '.$name.'<br>';     return 100; } function muti_var($a, $b){     echo 'a = '.$a.' b = '.$b.'<br>'; } function muti_var($a, $b){     echo "a = $a, b = $b"; } test('baby'); muti_var(10, 20); 
  | 
 
switch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
  | <?php function level($score){     echo $score/10;     $result = 'bad';     switch ((int)($score/10)){         case 10:         case 9:             $result = 'great';             break;         case 8:         case 7:             $result = 'not bad!';             break;         default:             $result = 'bad';             break;     }     return $result; } echo level(99); 
  | 
 
画图
1 2 3 4 5 6 
  | <?php $img = imagecreate(400, 300); imagecolorallocate($img, 255, 255, 255); imageellipse($img, 200, 200, 50, 50, imagecolorallocate($img, 255, 0, 0)); header('Content-type: image/png'); imagepng($img); 
  | 
 
登陆系统
前端的显示界面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 
  | <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>login</title> </head> <body > <form action="test.php" method = "post">     <div>name:         <input type = "text" name = "name">     </div>     <div>password:         <input type = "password" name = "password">     </div>     <input type = "submit" value ="login"> </form> </body> </html> 
  | 
 
后端连接数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 
  | <?php if (!isset($_POST['name'])) {     die('you don\'dont type anything man.'); } if (!isset($_POST['password'])) {     die('you don\'dont type anything man.'); } $name_get = $_POST['name']; $password_get = $_POST['password']; $conne = @mysqli_connect('localhost', 'root', ''); if($conne){     mysqli_select_db($conne, 'test');     $result = mysqli_query($conne, "SELECT * FROM test where name = '$name_get' ");     $tot = mysqli_num_rows($result);     $flag = false;     for($i=0; $i < $tot; $i++){         $result_arr = mysqli_fetch_assoc($result);         if ($result_arr['name'] == $name_get && $result_arr['password'] == $password_get){             $flag = true;             break;         }     }     if($flag == true){         echo "login successfully!";     }     else{         echo "unsuccessfully!".'<br>'."hey man";     } } else     echo '未连接数据库<br>'; 
  |