Blogger Information
Blog 62
fans 3
comment 1
visits 29745
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php类的相关操作与文件包含的两种方法区别
kiraseo_wwwkiraercom
Original
279 people have browsed it

php类的相关操作与文件包含的两种方法区别

include, require的错误对比

include 错误输出结果

require 错误输出结果

简述:

  1. include 引入文件时,如果文件不存在 提示warning 错误,但文件可以继续运行
  2. require 引入文件时,如果文件不存在 提示warning错误和Fatal erro 错误(警告错误),文件会禁止向下执行

代码如下

  1. <?php
  2. echo " include, require的区别与联系, 与当前脚本的作用域的关系<br/>";
  3. $p = "include //引入文件 如果文件不存在 提示warning 错误,但文件可以继续运行<br/>require //引入文件, 如果文件不存在 提示warning错误和Fatal erro 错误(警告错误),文件会禁止向下执行<br/>";
  4. echo $p."<br/>";
  5. echo '<hr/>';
  6. class Kira
  7. {
  8. public $name; //公有成员
  9. public $age; //公有成员
  10. private $fraction; //私有成员
  11. static $mail; //静态成员
  12. public function __construct($name,$age,$mail)
  13. {
  14. $this->name = $name;
  15. $this->age = $age;
  16. // 初始化静态属性
  17. self::$mail = $mail;
  18. }
  19. public function __get($name)
  20. {
  21. return $this->$name;
  22. }
  23. public function __set($name, $value)
  24. {
  25. return $this->$name = $value;
  26. }
  27. }
  28. $kira = new Kira('小丽',18,'admin@qq.com');
  29. echo '公有成员$name:'.$kira->name;
  30. echo '<br/>';
  31. echo '公有成员$age:'.$kira->age;
  32. echo '<br/>';
  33. echo '静态成员$mail:'.Kira::$mail;
  34. echo '<br/>';
  35. echo "私有成员默认为空,所有输出是没有的<br/>";
  36. echo '私有成员$fraction:'.$kira->fraction;
  37. echo '<br/>';
  38. $kira->fraction = 78;
  39. echo '<br/>';
  40. echo '私有成员被赋值后的<br/>';
  41. echo $kira->fraction;
  42. ?>

输出效果

1.include, require的区别与联系, 与当前脚本的作用域的关系

2.php类相关中成员定义与操作

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