2020年3月12日

    1. php1
    2. <?php
    3. $num = 1;
    4. if($num == 1 ){
    5. echo "操作1:登录";
    6. }else if ($num == 2){
    7. echo "操作2:退出";
    8. }else if($num == 2){
    9. echo "操作3:注册";
    10. }else if($num == 2){
    11. echo "操作4:修改密码";
    12. }
    13. $num1= 10;
    14. $num2= 10;
    15. $fu = '*';
    16. switch($fu){
    17. case"+";
    18. echo "加法", $num1 + $num2;
    19. break;
    20. case"-";
    21. echo "减法", $num1 - $num2;
    22. break;
    23. case"*";
    24. echo "乘法", $num1 * $num2;
    25. break;
    26. case"/";
    27. echo "除法", $num1 / $num2;
    28. break;
    29. case"%";
    30. echo "取余", $num1 % $num2;
    31. break;
    32. }
    33. $username ="贼帅";
    34. $password ="12333";
    35. $status = 2; //1正常 2封号
    36. if($username == "贼帅"){
    37. if($password == "12333"){
    38. if($status ==1){
    39. echo "登录成功";
    40. }else if{
    41. echo "禁止登录,封号";
    42. }
    43. }else {
    44. echo "密码错误";
    45. }
    46. }else{
    47. echo "账号不存在";
    48. }
    49. php2
    50. <?php
    51. $num = 1;
    52. if($num == 1 ){
    53. echo "操作1:登录";
    54. }else if ($num == 2){
    55. echo "操作2:退出";
    56. }else if($num == 2){
    57. echo "操作3:注册";
    58. }else if($num == 2){
    59. echo "操作4:修改密码";
    60. }
    61. $num1= 10;
    62. $num2= 10;
    63. $fu = '*';
    64. switch($fu){
    65. case"+";
    66. echo "加法", $num1 + $num2;
    67. break;
    68. case"-";
    69. echo "减法", $num1 - $num2;
    70. break;
    71. case"*";
    72. echo "乘法", $num1 * $num2;
    73. break;
    74. case"/";
    75. echo "除法", $num1 / $num2;
    76. break;
    77. case"%";
    78. echo "取余", $num1 % $num2;
    79. break;
    80. }
    81. $username ="贼帅";
    82. $password ="12333";
    83. $status = 2; //1正常 2封号
    84. if($username == "贼帅"){
    85. if($password == "12333"){
    86. if($status ==1){
    87. echo "登录成功";
    88. }else if{
    89. echo "禁止登录,封号";
    90. }
    91. }else {
    92. echo "密码错误";
    93. }
    94. }else{
    95. echo "账号不存在";
    96. }
    97. php3
    98. <?php
    99. $num = 1;
    100. if($num == 1 ){
    101. echo "操作1:登录";
    102. }else if ($num == 2){
    103. echo "操作2:退出";
    104. }else if($num == 2){
    105. echo "操作3:注册";
    106. }else if($num == 2){
    107. echo "操作4:修改密码";
    108. }
    109. $num1= 10;
    110. $num2= 10;
    111. $fu = '*';
    112. switch($fu){
    113. case"+";
    114. echo "加法", $num1 + $num2;
    115. break;
    116. case"-";
    117. echo "减法", $num1 - $num2;
    118. break;
    119. case"*";
    120. echo "乘法", $num1 * $num2;
    121. break;
    122. case"/";
    123. echo "除法", $num1 / $num2;
    124. break;
    125. case"%";
    126. echo "取余", $num1 % $num2;
    127. break;
    128. }
    129. $username ="贼帅";
    130. $password ="12333";
    131. $status = 2; //1正常 2封号
    132. if($username == "贼帅"){
    133. if($password == "12333"){
    134. if($status ==1){
    135. echo "登录成功";
    136. }else if{
    137. echo "禁止登录,封号";
    138. }
    139. }else {
    140. echo "密码错误";
    141. }
    142. }else{
    143. echo "账号不存在";
    144. }
    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width,initial-scale=1.0">
    6. <title>qianduan</title>
    7. </head>
    8. <body>
    9. <form accept="1.php" method="POST">
    10. <p>num:<input type="text" name="num"></p>
    11. <p>num2:<input type="text" name="num2"></p>
    12. <p>
    13. <input type="radio" name="fu" value="+" checked>+
    14. <input type="radio" name="fu" value="-" >-
    15. <input type="radio" name="fu" value="*" >*
    16. <input type="radio" name="fu" value="/" >/
    17. <input type="radio" name="fu" value="%" >%
    18. </p>
    19. <p><input type="submit"></p>
    20. </form>
    21. </body>
    22. </html>
    1. <?php
    2. echo '<a href ="1.html">回到计算器</a><br>';
    3. echo"<pre>";
    4. var_dump($_POST);
    5. echo"</pre>";
    6. $num =$_POST['num'];
    7. $num2 =$_POST['num2'];
    8. $fu =$_POST['fu'];
    9. if(! $num){
    10. exit("请将内容填写完整");
    11. }
    12. if(! $num2){
    13. die("请将内容填写完整");
    14. }
    15. if(! is_numeric($num)){
    16. exit("只能填写数字");
    17. }
    18. if(! is_numeric($num2)){
    19. exit("只能填写数字");
    20. }
    21. switch($fu){
    22. case'+':
    23. echo'加法' , $num + $num2;
    24. break;
    25. case'-':
    26. echo'减法' , $num - $num2;
    27. break;
    28. case'*':
    29. echo'乘法' , $num * $num2;
    30. break;
    31. case'/':
    32. echo'除法' , $num / $num2;
    33. break;
    34. case'%':
    35. echo'取余' , $num % $num2;
    36. break;
    37. }

    switch(原始值){
    case 1(原配值): // 原始值 == 匹配值,就执行冒号后的代码
    break;
    case 1(原配值): // 原始值 == 匹配值,就执行冒号后的代码
    break;
    //case…
    default:
    #假区间
    }

    break;跳出(结束)流程控制代码;
    php:当case匹配的时候
    当case下的代码执行直到遇到switch代码体结束
    遇break;停下

    action 把数据提交到哪里去
    method 请求方式
    GET url里面传参数
    POST 做提交数据
    $_GET $_POST 系统超全局变量,内容为数组,必须大写
    取反:原来是有值则执行真区间的代码
    有值的情况下不需要做任何操作
    没值的情况下就把代码停止运行 (exit)

    判断数据必须为数字
    is_numeric()判断一个变量是否数字“1”0 1.0 如果数字则返回true

    作业 - 图1