Blogger Information
Blog 53
fans 3
comment 0
visits 55276
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
11月16日-POST传值及PHP函数-PHP培训线上九期班
邯郸易住宋至刚
Original
1061 people have browsed it

一、POST传值

客户端代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>post</title>
  6. </head>
  7. <body>
  8. <form action="" method="post">
  9. <label for="email">邮箱:</label>
  10. <!--将用户输入的内容动态添加到value字段中, 创建具有粘性的表单-->
  11. <input type="email" id="email" name="email" value="<?php echo isset($_POST['email']) ? $_POST['email'] : ''; ?>">
  12. <label for="password">密码:</label>
  13. <input type="password" id="password" name="password" value="<?php echo isset($_POST['email']) ? $_POST['email'] : '';?>">
  14. <button>登录</button>
  15. </form>
  16. </body>
  17. </html>

服务器端代码

  1. if (isset($_POST['email'])) {
  2. echo $_POST['email'];
  3. echo '<hr>';
  4. echo '<pre>';
  5. print_r($_POST);
  6. } else { // 给个默认值
  7. $_POST['email'] = '';
  8. }

结果

二、PHP函数

1、trim() ltrim() rtrim()

代码:

  1. $str = ' ouyangke ';
  2. echo trim($str);
  3. echo '<hr>';
  4. $str = ' HuangRong ';
  5. echo lrim($str);
  6. echo '<hr>';
  7. $str = ' guojing ';
  8. echo rrim($str);

结果:

2、str_replace()

代码:

  1. $str = 'ouyangke huangrong guojing';
  2. echo str_replace('ouyangke','欧阳克',$str);

结果:

3、count()

代码:

  1. $arr = array(
  2. '欧阳克',
  3. '黄蓉',
  4. '郭靖'
  5. );
  6. echo count($arr);

结果:

4、array_merge()

代码:

  1. $arr1 = array(
  2. '欧阳克',
  3. '黄蓉'
  4. );
  5. $arr2 = array(
  6. '郭靖',
  7. '杨康'
  8. );
  9. $arr3 = array_merge($arr1,$arr2);
  10. echo '<pre>';
  11. print_r($arr3);

结果:

5、rsort()

代码:

  1. $arr = array(
  2. 'ouyangke',
  3. 'guojing',
  4. 'huangrong',
  5. );
  6. echo '<pre>';
  7. print_r($arr);
  8. echo '<hr>';
  9. rsort($arr);
  10. print_r($arr);
  11. echo '<hr>';

结果:

6、array_pop()

代码:

  1. $arr = array(
  2. '欧阳克',
  3. '黄蓉',
  4. '郭靖'
  5. );
  6. echo '<pre>';
  7. print_r($arr);
  8. array_pop($arr);
  9. print_r($arr);

结果:

三、手抄代码

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