【发布时间】:2014-03-06 12:47:32
【问题描述】:
构造在我的脚本中是如何工作的?
如果我不使用函数 __construct(),那么我的脚本将使用函数 Cat() 提供输出。 Construct 的正确使用方法是什么?
class Cat
{
function Cat1()
{
echo 'wow-wow';
}
function Cat()
{
echo 'meow';
}
function __construct()
{
echo 'meow'."</br>";
echo 'You are reading this because I am in</br>$billi my mind came from class cat which is using</br> function __construct(). That was my origin ';
}
}
$billi= new Cat();
【问题讨论】:
-
'为了向后兼容,如果 PHP 5 找不到给定类的 __construct() 函数,它将按类的名称搜索旧式构造函数。 -- stackoverflow.com/a/6872939/1612146
标签: php