【发布时间】:2016-04-08 00:26:17
【问题描述】:
我的模型类和其他类有一些问题,所以我做了这个简单的例子来解释我的问题:
class person{
public static $a = "welcome";
public function __construct(){
}
public static function getobject()
{
$v = new person();
return $v;
}
}
class student extends person{
public static $b = "World";
}
$st = student:getobject();//this will return person object but I want student object
echo $st->$b; // There is an error here because the object is not student
所以我想知道写什么而不是$v = new person(); 来获取最后一个继承类的对象。
【问题讨论】:
标签: php class oop inheritance