I have a script that need Strict Standards Off ~E_STRICT, but I cant understand how can I off strict standards on PHP. I have centos 6.4 with WHM installed VPS
If you want to repport all errors but stric, use error_reporting(E_ALL ^ E_STRICT);. If you want to repport all errors, use error_reporting(E_ALL); if you want to log all errors but not show them, use ini_set('display_errors', '0'); error_reporting(E_ALL); or change the display_errors directive in the php.ini manually and set it to off.
Related
I have a development version of PHP on Apache. I moved it to production and got this weird notices in my website. I don't have it on development version. How to enable these notices on my development version of website to fix them?
If you have access to your php.ini, then Björn answer is the way to go.
However, if you don't, or if you want to change a particular script / project error level, do this at the beginning of your code:
ini_set('display_errors', 1);
// Enable error reporting for NOTICES
error_reporting(E_NOTICE);
You can see which levels are available for error_reporting here: http://us2.php.net/manual/en/function.error-reporting.php.
It's always a good practice not to show any errors on production environments, but logging any weird behaviors and sending by mail to the administrator. NOTICES should only be enabled on development environments.
Change your php.ini file, the line that says error_reporting, to E_ALL.
I.e:
error_reporting = E_ALL
Seb is right, though you really should use constant for error_reporting().
error_reporting(E_NOTICE);
You can use bitwise operations to pick exactly the messages you want to display. For example:
// notices and warnings
error_reporting(E_NOTICE | E_WARNING);
// everything except errors
error_reporting(E_ALL ^ E_ERROR);
In my web app my boss wants me to use msql_* php functions but I can't even login because of PHP messages about these deprecated functions. How can I disable them in MAMP? Looking in this forum I've found the following rules to write inside php.ini
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On
disable_functions = "list of mysqli_* functions"
but this doesn't work. I've written this to all file php.ini of each php version contained in MAMP. The only thing that works is to put
display_errors = Off
but I can't use it like that otherwisw I won't even be able to see my programming/syntax error of other problems.
Here is my php.ini of php 5.6.10 inside /Applications/MAMP/bin/php/php5.6.10/conf/
Do you have any ideas? I know I should use new functions and not deprecated ones but it's not up to me and I can't disable all error messages...
I don't really have a solution for you, I'm sorry.
I did like that : in my .php files I put this code :
error_reporting(E_ALL ^ E_DEPRECATED); // without "~"
ini_set("display_errors", 1);
It seems to work.
Within the TEMATRES program (which is the program I use) there is a configuration file: config.tematres.php. This file has the following line:
Ini_set ('display_errors', 'On');
Error_reporting (E_ALL);
I changed it to:
Ini_set ('display_errors', 'On');
Error_reporting (E_ALL ^ E_DEPRECATED);
And thus I was able to solve the problem.
I'm using the built in PHP server and I'd like to suppress the strict warnings. In my php.ini file i have:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
...but it is still printing strict and deprecated notices. I verified that I was editing the correct ini file by checking a page with phpinfo().
In the built in webserver documentation, there is no mention of special error reporting rules.
I have also tried this:
error_reporting(E_ALL ^ E_STRICT ^ E_DEPRECATED);
ini_set("display_errors", "off");
print "changed stuff";
"changed stuff" is printed, along with strict and deprecated notices.
What do I need to do to suppress these errors in the PHP built in webserver? (Can this be done?)
Try changing like this [Reports all errors except STRICT ]
Through Code
<?php
error_reporting(E_ALL ^ E_STRICT);
Through PHP.ini
error_reporting = E_ALL ^ E_STRICT
I searched through my code (it's a very old codebase) and found several instances where the error reporting was manually set. Once i removed those it worked.
Check your files for error_reporting calls
I'm running ubuntu 10.04 + nginx + php-fpm 5.4
If I set display_errors = On in php.ini all errors are printed. If Instead I set that to off and then use ini_set('display_errors, '1'); directly in the script they will show as well but not the parse errors, just a blank page. I tried to play with error_reporting too and E_STRICT but I couldn't find a way!
If you disable display_errors in php.ini, and later enable it in your PHP script using ini_set(), it will only be enabled after the line containing that ini_set() call has been executed.
Parse errors occur before the PHP script even starts -- when the PHP file is parsed (hence the "parse error" name).
Which means they occur before your ini_set() has even a chance of being executed -- which means that, in your case, display_errors is not enabled when the parse error occurs ; and, as a consequence, you don't get anything displayed.
here I am years after this was answered, but I found a way around this.
For the script I'm writing, I created a second script which includes the ini_set() directives, followed by an include for the script I really am working on.
To with, here is test_run.php
<?php
ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL);
include('./my_script.php');
?>
Aside from turning on display_errors, you can also watch error logs. Typically, running Ubuntu + apache, your error log is going to be in /var/log/apache2/error_log. To watch in real time what's happening, you run something like tail -f /var/log/apache2/error_log.
This can sometimes be more straightforward than fussing with php settings.
**You must enable error displaying in the php.ini file **
I have added ( un-commented ) the following lines, and the parse errors are being displayed now.
error_reporting
Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
Development Value: E_ALL
Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
Try error_reporting(E_ALL);. Or the docs
I have a development version of PHP on Apache. I moved it to production and got this weird notices in my website. I don't have it on development version. How to enable these notices on my development version of website to fix them?
If you have access to your php.ini, then Björn answer is the way to go.
However, if you don't, or if you want to change a particular script / project error level, do this at the beginning of your code:
ini_set('display_errors', 1);
// Enable error reporting for NOTICES
error_reporting(E_NOTICE);
You can see which levels are available for error_reporting here: http://us2.php.net/manual/en/function.error-reporting.php.
It's always a good practice not to show any errors on production environments, but logging any weird behaviors and sending by mail to the administrator. NOTICES should only be enabled on development environments.
Change your php.ini file, the line that says error_reporting, to E_ALL.
I.e:
error_reporting = E_ALL
Seb is right, though you really should use constant for error_reporting().
error_reporting(E_NOTICE);
You can use bitwise operations to pick exactly the messages you want to display. For example:
// notices and warnings
error_reporting(E_NOTICE | E_WARNING);
// everything except errors
error_reporting(E_ALL ^ E_ERROR);