知道为什么我会收到此错误:
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 = new person("joe");
关于php - 警告 : Missing 1 argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4520605/