Blogger Information
Blog 25
fans 2
comment 0
visits 18567
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
12月2日作业
果莫个人博客
Original
621 people have browsed it
  1. <?php
  2. $site='php.cn';
  3. function Dizhi($webdizhi)
  4. {
  5. return $webdizhi .'欢迎你';
  6. }
  7. echo Dizhi($site);

  1. <?php
  2. $name ='peter zhu';
  3. $age = 30;
  4. $ismarried=false;
  5. echo '年龄:'.$age.'<br>';
  6. echo '是否已婚?:' . $ismarried.'<br>';
  7. echo '姓名:'.$name.'<br>';
  8. echo '姓名中的第三个字母:'.$name{2}.'<br>';
  9. echo print ('年龄:'.$age.'<br>');
  10. //echo '<br>';
  11. //print_r($name);
  12. //echo '<br>';
  13. //echo '姓名是:'.print_r($name,true).'<br>';
  14. //$data= range(1,20,2);
  15. //echo '<pre>'.print_r($data,true).'</pre>';
  16. //var_export($name);
  17. echo '<hr>';
  18. //var_export($data);
  19. var_dump($name,$age,$ismarried);

  1. <?php
  2. $user =[];
  3. $user[] =101;
  4. $user[] ='admin';
  5. $user[] ='admin@php.cn';
  6. $user=[101,'admin','admin@php.cn'];
  7. echo $user[2].'<hr>';
  8. echo '<pre>'.print_r($user,true).'</pre>';
  9. echo '<hr>';
  10. $res='';
  11. for ($i=0; $i < count($user); $i++ ){
  12. $res .=$user[$i].',';
  13. }
  14. echo rtrim($res,', ');
  15. echo '<hr>';
  16. $res='';
  17. foreach ($user as $item){
  18. $res .=$item.', ';
  19. }
  20. echo rtrim($res,', ');
  21. echo'<hr>';
  22. list($id,$name,$email)=$user;
  23. echo $id.'-'.$name.$email;
  24. $str = implode(',',$user);
  25. echo '<br>'.$str .'<br>';
  26. $sql="INSERT `users` SET `comment`='{$str}';";
  27. $arr=explode(',',$str);
  28. print_r($arr);
  29. echo'<br>';
  30. echo'<hr>';
  31. $user =['id'=>101,'name'=>'admin','email'=>'admin@php.cn'];
  32. //echo $user['email'];
  33. //echo '<br>';
  34. //echo '<pre>'.print_r($user,true).'<br>';
  35. //遍历
  36. foreach ($user as $key=>$value){
  37. echo '['.$key.']=>'.$value.'<br>';
  38. // echo [$key]=>$value;
  39. }
  40. $res = '';
  41. for ($i = 0 ; $i <count($user); $i++){
  42. $res.=current($user).', ';
  43. next($user);
  44. }
  45. echo rtrim($res,', ');
  46. echo'<hr>';
  47. extract($user);
  48. echo 'id2 = '. $id .'<br>'.'name=' .$name . '<br> email=' .$email.'<br>';
  49. $dsn = 'mysql:host=localhost;dbname=demo';
  50. $username='root';
  51. $password='root';
  52. $hebing=compact('dsn','username','password');
  53. print_r($hebing);
  54. echo'<br><hr>';
  55. $arr=array_values($user);
  56. echo '<pre>'.print_r($arr,true).'</pre>';

手抄:



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