Home > Backend Development > PHP Tutorial > PHP Strict Standards异常

PHP Strict Standards异常

WBOY
Release: 2016-06-13 10:40:43
Original
1049 people have browsed it

PHP Strict Standards错误

在部署项目时出现:Strict standards: Declaration of ... should be compatible with that of ...错误,我使用的是php 5.3.3

<?phpabstract class A {// 方法无参数public static function foo(){ echo 'bar'; }}abstract class B extends A {// 方法有参数public static function foo($str){ echo $str; }}?>
Copy after login
?
解决方法:
<?phpabstract class A {// 方法无参数public static function foo(){ echo 'bar'; }}abstract class B extends A {// 方法有参数public static function foo($str = NULL){ echo $str; }}?>
Copy after login
?
这是由于 php 5.3版本后。要求继承类必须在父类之后定义。否则就会出现Strict Standards: PHP Strict Standards: Declaration of .... should be compatible with that of .... 的错误提示。也就是说必须父类在前,继承类在后。

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template