4

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 ?

I use this:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
Spacedust
  • 558
  • 5
  • 12
  • 28
  • 1
    What type of errors is it showing, that will help us know what reporting settings will hide them. As a side note, you should probably have error logging enabled, and display of errors totally disabled. – WerkkreW Apr 02 '12 at 17:53
  • Strict Standards: Non-static method Flyspray::absoluteURI() should not be called statically in /home/admin/prace.jobs.pl/includes/constants.inc.php on line 30 – Spacedust Apr 02 '12 at 18:43

3 Answers3

3

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.

WerkkreW
  • 5,879
  • 3
  • 23
  • 32
0
error_reporting = (E_ALL ^ E_STRICT)

could this help?

GrexE
  • 1
  • Welcome to Server Fault - this is a ***VERY*** old question - if you are going to provide an answer to something this old please take the time to compose an *excellent* answer (providing a solution and an in-depth explanation of ***WHY*** your solution works). Just providing a line for someone to drop into a configuration file is not generally what we're looking for in an answer. Thanks :-) – voretaq7 Feb 21 '14 at 05:41
-1

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.