PHP7可以对非静态方式的方法进行静态形式的调用?
PHP版本:7.4
我有个类:
<?php
namespace App\Util;
class Test
{
public function test()
{
echo 78906;
}
}
然后我在控制器调用:
public function ddd()
{
Test::test();
}
上面代码正常输出78906,我试了加ini_set(‘error_reporting’, E_ALL); ini_set(‘error_reporting’, E_STRICT); declare(strict_types=1);还是正常运行。如何设置使他报错??我在php5.6环境这些设置是有效的。
而且看了一篇文章:codingdict.com/article/21475
以静态的方式调用非静态方法,不再支持。
为什么我的一直正常运行
ini_set('display_errors','On');
error_reporting(E_ALL);
加上面两句就报错了,配置问题
加上两句就报错了,配置问题
ini_set('display_errors','On');
error_reporting(E_ALL);
会有通知,但能运行成功
PHP Deprecated: Non-static method App\Util\Test::test() should not be called statically in
我的
7.1
和8.1
都直接报异常了3v4l.org/IEhpJ 可以看看这个