Blogger Information
Blog 19
fans 0
comment 0
visits 10996
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
函数练习,if语句
可乐
Original
670 people have browsed it

函数练习

  1. <?php
  2. $str = "'cleam bread'";
  3. echo $str;
  4. echo '<hr>';
  5. // 使用反斜线引用字符串
  6. $test = addslashes($str);
  7. echo $test;
  8. echo '<hr>';
  9. // 反引用一个引用字符串 除反斜杠
  10. $test = stripslashes($test);
  11. echo $test;
  12. echo '<hr>';
  13. // 将特殊字符转换为 HTML 实体
  14. $test = htmlspecialchars($str);
  15. echo $test;
  16. echo '<hr>';
  17. // 将特殊的 HTML 实体转换回普通字符
  18. $test = htmlspecialchars_decode($test);
  19. echo $test;
  20. echo '<hr>';
  21. // 转义元字符集
  22. $test = quotemeta($str);
  23. echo $test;
  24. echo '<hr>';
  25. // 字符串转大写
  26. $str = "'abcde'";
  27. $test = strtoupper($str);
  28. echo $test;
  29. echo '<hr>';
  30. // 字符串转小写
  31. $str = "'ABCDE'";
  32. $test = strtolower($str);
  33. echo $test;
  34. echo '<hr>';
  35. //使用uuencode编码一个字符串
  36. $str ="'hello'";
  37. $bianmazfc = convert_uuencode($str);
  38. echo $bianmazfc;
  39. echo '<br>';
  40. echo '<hr>';
  41. $bianmazfc = convert_uudecode($bianmazfc);
  42. echo $bianmazfc;
  43. echo '<hr>';
  44. // 数组转换成字符串
  45. $arr = [
  46. '巧克力',
  47. '饼干',
  48. '100g',
  49. '2021',
  50. ];
  51. echo implode('--',$arr);
  52. echo '<hr>';
  53. // 把字符串分割成数组
  54. $str = '巧克力面包0冰淇淋蛋糕1曲奇饼干';
  55. print_r( explode ('0',$str));
  56. echo '<hr>';
  57. //地址引用
  58. $a = '巧克力';
  59. $b = &$a;
  60. echo $a;
  61. echo '<hr>';
  62. echo $b;
  63. echo '<hr>';
  64. $a = '全麦面包';
  65. echo $a;
  66. echo '<hr>';
  67. echo $b;
  68. ?>

三元

  1. <?php
  2. $a = 10;
  3. $b = 5;
  4. $c = $a<$b ? ('面包'):('巧克力');
  5. echo '$c =' .$c;
  6. ?>

if语句

  1. <?php
  2. // date>19 echo“烤羊肉”,date<19 echo“杏仁豆腐”
  3. $t=date('d');
  4. if ($t>"19") {
  5. echo "杏仁豆腐!";
  6. }else{
  7. echo '烤羊肉';
  8. }
  9. ?>
  10. <?php
  11. // if 多条件判断
  12. $food = '';
  13. if($food == '糕点'){
  14. echo '桃花酥';
  15. }else if($food == '面包'){
  16. echo '海盐面包';
  17. }else if($food != '巧克力'){
  18. echo '喜欢';
  19. }else{
  20. echo '不喜欢';
  21. }
  22. ?>
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