知道我为什么会收到这个错误:
Warning: Missing argument 1 for person::__construct(),called in /home/fishbein/public_html/dev/OOP/index.PHP on line 5 and defined in /home/fishbein/public_html/dev/OOP/class_lib.PHP on line 6 Warning: Missing argument 1 for person::__construct(),called in /home/fishbein/public_html/dev/OOP/index.PHP on line 6 and defined in /home/fishbein/public_html/dev/OOP/class_lib.PHP on line 6
使用此代码:
<? class person { var $name; function __construct($persons_name) { $this->name = $persons_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?>
我也在我的索引文件中使用它:
$tyler = new person("Tyler");
实例化时你做了:$obj = new person();而不是$obj =新人(“乔”);
原文链接:https://www.f2er.com/php/133231.html