03

    xiaoxiao2021-12-14  31

    注意计算机获取的都是字符串
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <?php //isset为真表示提交了按钮 if(isset($_POST['button'])) { $num=$_POST['num']; if(is_numeric($num)) { $num=$num+0; if(is_int($num)) { if($num%2==0) { echo $num.'是偶数'; } else { echo "{$num}是偶数"; } } else { echo "{$num} 不是整数"; } } else { echo "{$num} 不是数字"; } } ?> <form id="form1" name="form1" method="post" action=""> <table width="500" border="1" align="center"> <tr> <th colspan="2">请输入数字</th> </tr> <tr> <td width="240">请输入一个数</td> <td width="244"><input type="text" name="num" id="num" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="button" id="button" value="提交" /></td> </tr> </table> </form> </body> </html>

    判断瑞年 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <?php if(isset($_POST['button'])) { $year=$_POST['year']; if(is_numeric($year)) { $year+=0; if(is_int($year)) { if($year>0) { if($year%4==0 && $year0!=0 || $year@0==0) { echo "{$year} 是瑞年"; } else { echo $year.' 不是瑞年'; } } else { echo $year.' 不是负数'; } } else { echo $year.' 不是整数'; } } else { echo $year.' 不是数字'; } } ?> <form id="form1" name="form1" method="post" action=""> <table width="500" border="1" align="center"> <tr> <td colspan="2" align="center">判断瑞年</td> </tr> <tr> <td>请输入年份</td> <td align="center"><input type="text" name="year" id="year" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="button" id="button" value="提交" /></td> </tr> </table> </form> </body> </html>
    多分支 if(条件) { } elseif(条件) { } elseif(条件) { } else { } for循环 for(;;) { //死循环 } foreach 遍历数组 foreach(数组 as 值变量) 函数 function function 函数名(参数){ //函数体 [return] }
    转载请注明原文地址: https://ju.6miu.com/read-971472.html

    最新回复(0)