Blogger Information
Blog 28
fans 0
comment 0
visits 15772
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0808作业 回调函数和递归函数
︷肉園耔︷
Original
630 people have browsed it
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport"
  6. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8. <title>Document</title>
  9. </head>
  10. <body>
  11. <form method="post">
  12. <input type="text" name="first" />
  13. <select name="s" id="">
  14. <option value="+">+</option>
  15. <option value="-">-</option>
  16. <option value="*">*</option>
  17. <option value="%">%</option>
  18. <option value="/">/</option>
  19. </select>
  20. <input type="text" name="second">
  21. <input type="submit" value="结果">
  22. </form>
  23. </body>
  24. </html>
  25. <?php
  26. //判断是否PHP的得到值
  27. $first=$_POST["first"]; //获得name为first的值
  28. $v=$_POST["s"]; //获取name为s的值
  29. $second=$_POST["second"]; //获取name为second的值
  30. if($v=="+"){
  31. echo $first."+".$second."结果为".($first+$second);
  32. }elseif($v== "-"){
  33. echo $first."-".$second."结果为".($first-$second);
  34. }elseif($v== "*"){
  35. echo $first."*".$second."结果为".($first-$second);
  36. }elseif($v=="/"){
  37. if($second ==0){
  38. echo "除数不能为0";
  39. }else{
  40. echo $first."/".$second."结果为".($first/$second);
  41. }
  42. }elseif($v == "%"){
  43. if($second ==0){
  44. echo "除数不能为0";
  45. }else{
  46. echo $first."%".$second."结果为".($first%$second);
  47. }
  48. }
  49. function demo(string $name):string{
  50. return '你好'.$name;
  51. }
  52. //demo('灭绝师太');
  53. echo call_user_func('demo','灭绝老师');
  54. echo call_user_func_array('demo',['朱老师']);
  55. //递归函数 函数自身调用自身,但必须在调用自身前有条件判断,否则无限调用下去
  56. //声明缓存目录
  57. ob_clean();
  58. function del($dir){
  59. if(is_dir($dir)){
  60. //成功打开目录流
  61. if($handle = opendir($dir)){
  62. while(($file=readdir($handle))
  63. !==false){
  64. if($file !='.'&& $file !='..'){
  65. if(is_dir($dir.'\\'.$file)){
  66. delete_dir_file($dir.'\\'.file);
  67. }else{
  68. unlink($dir.'\\'.$file);
  69. }
  70. }
  71. }
  72. }
  73. closedir($handle);
  74. }
  75. }
  76. $path = __DIR__;
  77. del($path);
  78. ?>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post