View previous topic :: View next topic |
Author |
Message |
marlin -
Joined: 01 Sep 2006 Posts: 11
|
Posted: Sat Jul 02, 2022 8:23 pm Post subject: I don't like being warned |
|
|
I copied a bunch of php scripts that have been working fine to a new computer. In all of the scripts I now get multiple warning messages complaining about undefined variables. They only serve to make the output ugly. The scripts have long been debugged; and still work properly, except for the messages..
I ran phpinfo.php which showed the error_reporting code to be 32765. I also inspected the php.ini file which included the directive
error_reporting = E_ALL ^ E_WARNING.
Finally, I inserted the command
echo 'error_reporting: '. error_reporting( ) ;
as the first line in one of my scripts; and the result was 32765. Now the code for all errors is 32767 and 2 for warnings. Thus 32767 - 2 = 32765.
So why are the warnings appearing?
I'm running the scripts on a windows laptop with the Abyss Web Server, |
|
Back to top |
|
 |
admin Site Admin
Joined: 03 Mar 2002 Posts: 1284
|
Posted: Sat Jul 09, 2022 9:01 pm Post subject: Re: I don't like being warned |
|
|
marlin,
PHP has several flavors of warnings. E_WARNING is only for a single kind of them.
You could be getting warnings about deprecation or other issues and these are not usually covered by E_WARNING.
Try setting in php.ini:
Code: | error_reporting = E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED |
_________________ Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com |
|
Back to top |
|
 |
marlin -
Joined: 01 Sep 2006 Posts: 11
|
Posted: Tue Jul 12, 2022 12:57 am Post subject: |
|
|
As I mention, the warnings are about undefined variables. It dawned on me that that is a good thing on my laptop, because that is where I debug programs and it's good to have undefined variables flagged because, although many are by design, some are typos I would want to know about.
The web hosting service where I upload scripts doesn't show warnings, which is just what I want.
That still begs the question of how to squelch warnings on my local machine. |
|
Back to top |
|
 |
pkSML -
Joined: 29 May 2006 Posts: 951 Location: Michigan, USA
|
Posted: Wed Jul 13, 2022 12:31 pm Post subject: |
|
|
marlin wrote: | That still begs the question of how to squelch warnings on my local machine. |
You can find examples here: https://www.php.net/manual/en/function.error-reporting.php
You can set the error reporting level right in your script, and just change that level when you send to production.
You can also set it in your php.ini file, as Aprelium guided you:
admin wrote: | error_reporting = E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED |
This will turn off warnings, notices, deprecation notices, etc.
You can also change your php.ini value for display_errors. Set it to off and you should be a lot happier. _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
 |
|