static - 请问下PHP中5.3之前的版本和5.3之后的版本在静态化类 上面有什么区别吗?
Jun 06, 2016 pm 08:35 PM
我接触PHP 都是接触5.6版本的以前的版本没接触 求高手帮忙,
我的PHP 用5.3版本就不报错,
已改成5.6版本就开始报错说静态类不能使用, static public function(){ ....}
<code>**Strict Standards: Non-static method cls_image::gd_version() should not be called statically in F:\WWW\weixin\includes\lib_base.php on line 276 Strict Standards: Non-static method cls_image::gd_version() should not be called statically in F:\WWW\weixin\includes\lib_base.php on line 276 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in F:\WWW\weixin\includes\cls_template.php on line 300 Strict Standards: Non-static method cls_image::gd_version() should not be called statically in F:\WWW\weixin\includes\lib_base.php on line 276** </code>
回复内容:
我接触PHP 都是接触5.6版本的以前的版本没接触 求高手帮忙,
我的PHP 用5.3版本就不报错,
已改成5.6版本就开始报错说静态类不能使用, static public function(){ ....}
<code>**Strict Standards: Non-static method cls_image::gd_version() should not be called statically in F:\WWW\weixin\includes\lib_base.php on line 276 Strict Standards: Non-static method cls_image::gd_version() should not be called statically in F:\WWW\weixin\includes\lib_base.php on line 276 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in F:\WWW\weixin\includes\cls_template.php on line 300 Strict Standards: Non-static method cls_image::gd_version() should not be called statically in F:\WWW\weixin\includes\lib_base.php on line 276** </code>
php的语法变规范,变严谨了,所以以前不符合规范的代码就会给提示,这是好事,你要习惯。
ecshop
的cls_image
库中gd_version
不是一个静态方法
http://de2.php.net/manual/en/language.oop5.static.php
Calling non-static methods statically generates an E_STRICT level warning.
用静态方式调用一个非静态方法会导致一个 E_STRICT 级别的错误。
http://us2.php.net/manual/en/errorfunc.constants.php
E_STRICT Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code. Since PHP 5 but not included in E_ALL until PHP 5.4.0
E_STRICT 启用 PHP 对代码的修改建议,以确保代码具有最佳的互操作性和向前兼容性。从 PHP 5.4 开始被默认启用。

인기 기사

인기 기사

뜨거운 기사 태그

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드

PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법
