1

I'm trying to add a custom error handler to my site, but in doing so have discovered that my webhost's PHP error reporting settings and those of my localhost (default XAMPP) vary considerably.

While I thought I was programming to E_STRICT like a good little boy, adding the error handler to my webhost revealed craploads of Runtime Notices. Example:

Runtime notice
strtotime() [function.strtotime]: It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable or 
the date_default_timezone_set() function. In case you used any of those methods
and you are still getting this warning, you most likely misspelled the
timezone identifier. We selected 'America/Chicago' for 'CST/-6.0/no DST' instead
In /home/...

Clearly this isn't a red-alert, showstopping error. But what bothers me is that it doesn't show up on my localhost. I'd certainly like to improve my code by addressing these sorts of issues if I could see them!

I've looked through both php.ini files, and my webhost's setting is error_reporting = E_ALL & ~E_NOTICE whereas mine was error_reporting = E_STRICT, which I had thought was better. However, changing mine to match and rebooting the server doesn't seem to have accomplished anything.

Could someone please point me in the right direction?

EDIT - it seems I didn't make myself clear. I know how to solve the problem the notice is finding. MY PROBLEM is that my development PHP and my webhost's PHP are not throwing the same level of errors. The webhost is reporting these runtime notices while my testbed does not. And I don't know how to make my testbed show these errors.

7
  • why not to correct an error instead of altering reporting level?? Commented Jan 29, 2011 at 7:01
  • I want to correct the errors, but currently I can only see these error messages on the web host. Identical files on the localhost don't trip any errors, so I'm assuming there is a discrepancy in error reporting levels between the two servers. It's a bitch to debug if I can only do it on a live installation! :-( Commented Jan 29, 2011 at 7:03
  • I see now, took it wrong at first, sorry Commented Jan 29, 2011 at 7:12
  • are you sure you're editing the right php.ini file? setting the same error_reporting level and restarting the server should produce the same output, maybe find out the apache-loaded one in <?php phpinfo(); ?> ? Commented Jan 29, 2011 at 7:17
  • I used phpinfo. The webhost is running 5.2.15 from 2010/12/15 whereas my XAMPP installation is running 5.3.1, which is from 2009/11/20. I'm going to update the local version and see how it goes. Commented Jan 29, 2011 at 7:20

2 Answers 2

1
  1. In php ini set date.timezone = "America/New_York"
  2. In your code set date_default_timezone_set()
  3. In .htaccess set php_value date.timezone "America/New_York"

Of caurse, America/New_York is example.

Sign up to request clarification or add additional context in comments.

Comments

0
  1. No, E_STRICT is already highest of them. Keep it.

  2. Your PHP version on localhost is outdated. Upgrade it.

  3. Then add date_default_timezone_set() to the application's config file to make correction of this error portable.

1 Comment

as an alternative, put date.timezone = America/Chicago (or your timezone) in the php.ini file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.