I've upgraded from PHP 5.3 to PHP 5.4 today. Now my script is displaying a lot of error messages. How to hide them without using error_reporting(0); inside php file ?
In PHP 5.4 E_STRICT became part of E_ALL - (documentation). My recommendation would be to turn the directive to display errors to off, and to log errors instead, this would be done by setting the following in your php.ini:
display_errors = off
log_errors = on
error_log = /path/to/logs/php_error.log
If you do not want to go down this route and still wish to display errors and simply emulate the PHP <5.4 functionality you would be best off doing something like this:
error_reporting = E_ERROR | E_WARNING | E_PARSE
It should also be mentioned that various people have reported the inability to exclude E_STRICT from E_ALL in such a way as you have tried as a bug, so this might change in a later release to allow for the functionality you are used to.
Regular methods are meant to be called from an INSTANCE of a class (Object).
Like this:
$object = new Class();
$object->function();
However you are calling it straight from the class.
Like this:
class::function();
Here is what STATIC methods are for.
change this:
public function absoluteURI()
To this:
public static function absoluteURI()
I recommend you always code stricly, so NOT turn off the strict errors. Why?
Your example proves it. You were using a regular method to do something it shouldn't do.
So instead of of turning off the strict errors, make these easy minor fixes to your code :)
It's worth it, i promise.
A good programmer is always open to neater coding, and will take the time to learn it.
In PHP 5.4 E_STRICT became part of E_ALL - (documentation). My recommendation would be to turn the directive to display errors to off, and to log errors instead, this would be done by setting the following in your php.ini:
If you do not want to go down this route and still wish to display errors and simply emulate the PHP <5.4 functionality you would be best off doing something like this:
It should also be mentioned that various people have reported the inability to exclude E_STRICT from E_ALL in such a way as you have tried as a bug, so this might change in a later release to allow for the functionality you are used to.
could this help?
Regular methods are meant to be called from an INSTANCE of a class (Object).
Like this: $object = new Class(); $object->function();
However you are calling it straight from the class.
Like this: class::function();
Here is what STATIC methods are for.
change this: public function absoluteURI()
To this: public static function absoluteURI()
I recommend you always code stricly, so NOT turn off the strict errors. Why? Your example proves it. You were using a regular method to do something it shouldn't do.
So instead of of turning off the strict errors, make these easy minor fixes to your code :) It's worth it, i promise.
A good programmer is always open to neater coding, and will take the time to learn it.