Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form method="post">
<input type="text" name="first" />
<select name="s" id="">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="%">%</option>
<option value="/">/</option>
</select>
<input type="text" name="second">
<input type="submit" value="结果">
</form>
</body>
</html>
<?php
//判断是否PHP的得到值
$first=$_POST["first"]; //获得name为first的值
$v=$_POST["s"]; //获取name为s的值
$second=$_POST["second"]; //获取name为second的值
if($v=="+"){
echo $first."+".$second."结果为".($first+$second);
}elseif($v== "-"){
echo $first."-".$second."结果为".($first-$second);
}elseif($v== "*"){
echo $first."*".$second."结果为".($first-$second);
}elseif($v=="/"){
if($second ==0){
echo "除数不能为0";
}else{
echo $first."/".$second."结果为".($first/$second);
}
}elseif($v == "%"){
if($second ==0){
echo "除数不能为0";
}else{
echo $first."%".$second."结果为".($first%$second);
}
}
function demo(string $name):string{
return '你好'.$name;
}
//demo('灭绝师太');
echo call_user_func('demo','灭绝老师');
echo call_user_func_array('demo',['朱老师']);
//递归函数 函数自身调用自身,但必须在调用自身前有条件判断,否则无限调用下去
//声明缓存目录
ob_clean();
function del($dir){
if(is_dir($dir)){
//成功打开目录流
if($handle = opendir($dir)){
while(($file=readdir($handle))
!==false){
if($file !='.'&& $file !='..'){
if(is_dir($dir.'\\'.$file)){
delete_dir_file($dir.'\\'.file);
}else{
unlink($dir.'\\'.$file);
}
}
}
}
closedir($handle);
}
}
$path = __DIR__;
del($path);
?>