【发布时间】:2012-07-10 00:41:58
【问题描述】:
我最近在阅读一些关于 PHP 面向对象编程的文章,并遇到了这样的事情:
class a {}
$temp = new a();
$temp->newfiled = 20; // This field is not present within the class
以上代码在 PHP 5.3 中运行良好
为什么 PHP 会抛出错误?我来自 Java 背景,我们只能使用在类中定义的字段。
更新: 将 php.ini 编辑为 error_reporting = E_ALL | E_STRICT,但它继续隐藏错误。
另外,这是 PHP 的一个特性吗?
【问题讨论】:
标签: php