Blogger Information
Blog 37
fans 1
comment 0
visits 27115
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1118_php基础知识6 九期第16课
叮叮当当
Original
678 people have browsed it

1. 练习post传值(手写)

  1. <?php
  2. # 2、POST 请求
  3. # POST请求, 参数不是通过URL传递, 而是通过请求头header, 适合敏感信息, 数据量大
  4. # 多用表单提交, php通过超全局变量$_POST获取, $_POST是一个数组, 键名就是POST参数名
  5. //print_r($_POST);
  6. echo '邮箱:' ;
  7. echo isset($_POST['email']) ? $_POST['email'] : '';
  8. echo '<hr>';
  9. ?>
  10. <!DOCTYPE html>
  11. <html lang="en">
  12. <head>
  13. <meta charset="UTF-8">
  14. <title>post</title>
  15. </head>
  16. <body>
  17. <form action="" method="post">
  18. <label for="email">邮箱:</label>
  19. <input type="email" id="email" name="email" value="<?php echo isset($_POST['email']) ? $_POST['email'] : ''; ?>" required>
  20. <label for="password">密码:</label>
  21. <input type="password" id="password" name="password" value="" required>
  22. <button>登录</button>
  23. </form>
  24. </body>
  25. </html>

2. 函数自行学习一些

系统函数

  1. <?php
  2. /*
  3. * 一、字符串函数
  4. */
  5. # 1. strtolower() 将字符串转化为小写
  6. $str = 'SHOPPING';
  7. echo strtolower($str);
  8. echo '<br>';
  9. $str = 'ILoveYou';
  10. echo strtolower($str);
  11. echo '<hr>';
  12. # 2. strtoupper 将字符串转化为大写
  13. $str = 'shopping';
  14. echo strtoupper($str);
  15. echo '<br>';
  16. $str = 'ILoveYou';
  17. echo strtoupper($str);
  18. echo '<hr>';
  19. # 3. strlen() 获取字符串长度
  20. # 4. trim() 去除字符串首尾处的空白字符(或者其他字符)
  21. # 5. ltrim() 去除字符串开头的空白字符(或者其他字符)
  22. # 6. rtrim() 去除字符串结尾的空白字符(或者其他字符)
  23. $str = '~ shop ~';
  24. echo '始长: '. strlen( $str );
  25. echo '<br>';
  26. echo trim( $str,'~' ) . ' --> ' . strlen( trim( $str,'~' ) );
  27. echo '<br>';
  28. $str2 = trim( trim( $str,'~' ) );
  29. echo trim($str2). ' --> ' . strlen($str2);
  30. echo '<br>';
  31. echo ltrim( $str,'~' ) . ' --> ' . strlen( ltrim( $str,'~' ) );
  32. echo '<br>';
  33. $str2 = ltrim( ltrim( $str,'~' ) );
  34. echo ltrim($str2). ' --> ' . strlen($str2);
  35. echo '<br>';
  36. echo rtrim( $str,'~' ) . ' --> ' . strlen( rtrim( $str,'~' ) );
  37. echo '<br>';
  38. $str2 = rtrim( rtrim( $str,'~' ) );
  39. echo rtrim($str2). ' --> ' . strlen($str2);
  40. echo '<hr>';
  41. # 7. str_replace() 字符串替换
  42. $str = '我要shopping';
  43. echo str_replace('shopping','购物', $str );
  44. echo '<hr>';
  45. # 8. strpbrk() 在字符串中搜索指定字符中的任意一个
  46. # 返回指定字符第一次出现的位置开始的剩余部分。若未找到,返回false
  47. $str = 'I love you';
  48. echo strpbrk($str,'i'); //未找到
  49. echo '<br>';
  50. echo strpbrk($str,'ly'); //先找到了l
  51. echo '<hr>';
  52. # 9. explode() 将字符串分割为数组
  53. $str = 'I love you';
  54. print_r( explode(' ', $str) );
  55. echo '<hr>';
  56. # 10. implode() 把数组元素组合为字符串
  57. $arr = ['I','love','you'];
  58. echo implode(' ', $arr);
  59. echo '<hr>';
  60. # 11. md5() 将字符串进行md5加密
  61. $str = '123456';
  62. echo md5($str);
  63. echo '<hr>';
  64. /*
  65. * 二、数组函数
  66. */
  67. # 1. count() 数组中元素的数量
  68. $arr = ['take','it','easy'];
  69. echo count($arr);
  70. echo '<hr>';
  71. # 2. array_merge() 数组合并
  72. $arr1 = ['apple', 'pear'];
  73. $arr2 = ['banana','cherry'];
  74. print_r( array_merge($arr1,$arr2) );
  75. echo '<hr>';
  76. # 3. in_array() 数组中是否存在指定的值
  77. $arr = [ 'take', 'it', 'easy' ];
  78. echo in_array('it',$arr);
  79. echo '<hr>';
  80. # 4. sort() 对数值数组进行升序排序
  81. # 5. rsort() 对数值数组进行降序排序
  82. $arr = [ 'i', 'wanna', 'a', 'cup', 'of', 'coffee'];
  83. sort($arr);
  84. print_r( $arr );
  85. echo '<br>';
  86. rsort($arr);
  87. print_r($arr);
  88. echo '<hr>';
  89. # 6. array_unique() 数组去重
  90. $arr = ['take', 'take', 'it', 'it', 'easy' ];
  91. print_r( array_unique($arr) );
  92. echo '<hr>';
  93. # 7. array_push() 将元素插入数组的末尾
  94. $arr = ['come','on'];
  95. array_push($arr,'boy');
  96. print_r($arr);
  97. echo '<hr>';
  98. # 8. array_pop() 删除数组中的最后一个元素
  99. $arr = ['come','on','boy'];
  100. array_pop($arr);
  101. print_r($arr);
  102. echo '<hr>';


Correcting teacher:查无此人查无此人

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