2020年3月12日
php1
<?php
$num = 1;
if($num == 1 ){
echo "操作1:登录";
}else if ($num == 2){
echo "操作2:退出";
}else if($num == 2){
echo "操作3:注册";
}else if($num == 2){
echo "操作4:修改密码";
}
$num1= 10;
$num2= 10;
$fu = '*';
switch($fu){
case"+";
echo "加法", $num1 + $num2;
break;
case"-";
echo "减法", $num1 - $num2;
break;
case"*";
echo "乘法", $num1 * $num2;
break;
case"/";
echo "除法", $num1 / $num2;
break;
case"%";
echo "取余", $num1 % $num2;
break;
}
$username ="贼帅";
$password ="12333";
$status = 2; //1正常 2封号
if($username == "贼帅"){
if($password == "12333"){
if($status ==1){
echo "登录成功";
}else if{
echo "禁止登录,封号";
}
}else {
echo "密码错误";
}
}else{
echo "账号不存在";
}
php2
<?php
$num = 1;
if($num == 1 ){
echo "操作1:登录";
}else if ($num == 2){
echo "操作2:退出";
}else if($num == 2){
echo "操作3:注册";
}else if($num == 2){
echo "操作4:修改密码";
}
$num1= 10;
$num2= 10;
$fu = '*';
switch($fu){
case"+";
echo "加法", $num1 + $num2;
break;
case"-";
echo "减法", $num1 - $num2;
break;
case"*";
echo "乘法", $num1 * $num2;
break;
case"/";
echo "除法", $num1 / $num2;
break;
case"%";
echo "取余", $num1 % $num2;
break;
}
$username ="贼帅";
$password ="12333";
$status = 2; //1正常 2封号
if($username == "贼帅"){
if($password == "12333"){
if($status ==1){
echo "登录成功";
}else if{
echo "禁止登录,封号";
}
}else {
echo "密码错误";
}
}else{
echo "账号不存在";
}
php3
<?php
$num = 1;
if($num == 1 ){
echo "操作1:登录";
}else if ($num == 2){
echo "操作2:退出";
}else if($num == 2){
echo "操作3:注册";
}else if($num == 2){
echo "操作4:修改密码";
}
$num1= 10;
$num2= 10;
$fu = '*';
switch($fu){
case"+";
echo "加法", $num1 + $num2;
break;
case"-";
echo "减法", $num1 - $num2;
break;
case"*";
echo "乘法", $num1 * $num2;
break;
case"/";
echo "除法", $num1 / $num2;
break;
case"%";
echo "取余", $num1 % $num2;
break;
}
$username ="贼帅";
$password ="12333";
$status = 2; //1正常 2封号
if($username == "贼帅"){
if($password == "12333"){
if($status ==1){
echo "登录成功";
}else if{
echo "禁止登录,封号";
}
}else {
echo "密码错误";
}
}else{
echo "账号不存在";
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>qianduan</title>
</head>
<body>
<form accept="1.php" method="POST">
<p>num:<input type="text" name="num"></p>
<p>num2:<input type="text" name="num2"></p>
<p>
<input type="radio" name="fu" value="+" checked>+
<input type="radio" name="fu" value="-" >-
<input type="radio" name="fu" value="*" >*
<input type="radio" name="fu" value="/" >/
<input type="radio" name="fu" value="%" >%
</p>
<p><input type="submit"></p>
</form>
</body>
</html>
<?php
echo '<a href ="1.html">回到计算器</a><br>';
echo"<pre>";
var_dump($_POST);
echo"</pre>";
$num =$_POST['num'];
$num2 =$_POST['num2'];
$fu =$_POST['fu'];
if(! $num){
exit("请将内容填写完整");
}
if(! $num2){
die("请将内容填写完整");
}
if(! is_numeric($num)){
exit("只能填写数字");
}
if(! is_numeric($num2)){
exit("只能填写数字");
}
switch($fu){
case'+':
echo'加法' , $num + $num2;
break;
case'-':
echo'减法' , $num - $num2;
break;
case'*':
echo'乘法' , $num * $num2;
break;
case'/':
echo'除法' , $num / $num2;
break;
case'%':
echo'取余' , $num % $num2;
break;
}
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