PHP构造不工作?
我有以下代码:PHP构造不工作?,php,oop,class,constructor,Php,Oop,Class,Constructor,我有以下代码: <?php class Human() { function __construct() { echo "A human was born"; } } $Person1 = new Human(); ?> 我试图让它打印出“人类诞生了”,但它就是没有 在类人之后删除() <?php class Human { function __construct() { echo "
<?php
class Human()
{
function __construct()
{
echo "A human was born";
}
}
$Person1 = new Human();
?>
我试图让它打印出“人类诞生了”,但它就是没有 在类人
之后删除()
<?php
class Human
{
function __construct()
{
echo "A human was born";
}
}
$Person1 = new Human();
?>
如果语法有错误,应将类声明为:
class Human {
function __construct()
{
echo "A human was born";
}
}
如果在类的名称后面没有
()
。打开错误报告,您应该会得到一个解析错误15k,回答对于+7来说太本地化了-典型:)