I cannot view PHP error on Apache of my mac because every time when I changed from php.ini file to display_error On. But when i restart and open the php.info file, it still says display_error Off. Searched for all php.ini file and changed all off to on but still same result. Help please
Use error_reporting(); at the begining of your PHP main file. It will ignore php.ini and obey the error level you set there.
Also, check that your php.ini is not beign use / locked before you make changes on it?
Related
Basically, I have an issue whenever PHP should show an error; it won't load the .php file at all.
For example, let's say that I make a mistake while writing:
<?php
function foo($value) { return $value; };
foo(); //missing value, should display a warning or error
?>
That won't show an error, it will just say "This page isnt working".
I checked my php.ini file, but what I found inside seems legit:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
What could be the cause of this issue? And of course, how to solve it?
You are most probably looking at the wrong error log file.
For PHP there are basically 3 options, depending on what error_log in php.ini is set to. To determine the correct value, add a file with the contents <php phpinfo(); and open it in your browser. This should show a list of all php settings. I recommend this method instead of just opening php.ini because it avoids confusion that might be caused by multiple php.ini and conf.d files.
In that page, search for error_log. This setting determines your log location. If it is not set, that means that PHP is logging to the SAPI interface. Look in your your webserver logs (location depends on OS and used webserver, for Ubuntu and Apache it would be /var/log/apache2/error.log).
If there is a file path in error_log that is the path of your PHP error log. Just open it and the error should be there.
If error_log is set to syslog, PHP logs to your system log. For windows, that is the event log (can be opened by searching for "event log" from the taskbar). For Unix that is the syslog, usually /var/log/syslog but might vary depending on configuration and distro.
Please note that in case you are using php-fpm there are additional FPM log settings, which you also would need to check.
I checked which php.ini is used with phpinfo(), so I'm editing the right php config file.
In that php.ini file (and in phpinfo() details) I have display_errors at On and error_reporting at E_ALL.
BUT when I have a PHP error, most of the time I find no log (in the file specified by error_log, nor in the file specified in apache vhost, nor in /var/syslog), and only a blank page displayed.
I also tried to use the ini_set("display_errors", 1) but that didn't change anything.
One thing was weird, I had no php5 folder in /var/log (I created it, and configured error_log to use it).
Any idea would be much appreciated, that's not so great to code without knowing anything about the errors you have !
P.S. I'm using PHP 5.4 & Symfony2 (using the app_dev.php file), on Debian Wheezy.
Edit : Error logs now work thanks to #martinezjc , but still having a blank page in Apache.
You can create a custom directory, remember to assign apache permission
mkdir /var/log/php-5-4
chown www-data /var/log/php-5-4
The in the php.ini file
error_log = /var/log/php-5-4/php_errors.log
This link talk about more about logs, you can check it http://doc.exyks.org/wiki/Server_php_log_configuration
I can't see any PHP errors. I have tried every trick I can find to turn error reporting on, but nothing works.
display_errors is on and error_logging is on, but when I view any page with an error, I get a blank page.
/var/log/php.log does not exist.
if I set a local logfile, Nothing gets created.
The file I have been testing with is
<?php
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
ini_set('error_log','script_errors.log');
ini_set('log_errors','On');
$a=
phpinfo();
?>
any other ideas?
You probably need to set it in .htaccess, httpd.conf or php.ini (depending on your server or hosting company). You most likely have a parse error, which means your script never gets to the point where it can turn on the error reporting.
Have you tried editing the actual ini file as opposed to trying to change it at runtime? You can also try using ini_get('display_errors'); to see if your change took effect. If neither of those work I would say your installation is either faulty or very restricted.
Run phpinfo() as the first thing in the script, before you try any of the ini_set options. If your host has those ini functions disabled/restricted, you'll most likely not ever get to phpinfo.
Does the userID the webserver's running under have write permissions in the directory you're running this script from? It could be failing to open your test log file and kill the script that way.
Once you get some phpinfo() output, you'll be able to see if/where PHP is logging errors. It could be going into the server's general error_log, or some other location entirely.
i solved this problem by my hosing website
cpanel-> php config ->display error on
I am running the latest version of MAMP on Snow Leopard.
My php.ini file has been configured to display errors. display_errors = on. The phpinfo(); page displays the status of error reporting, it is on. I have restarted my web server several times.
I've searched through Google, and I cannot find any similar problem. Everyone just says to do exactly what I have done, but it is not working. The pages will just remain blank, (with no reporting), if I intentionally place errors.
Any thoughts as to what the problem may be?
For any future posters who run into this issue...
I was having the same issue and found that I was making changes to the wrong php.ini files. Run phpinfo and find the path to the active php.ini file to make sure you're editing the correct one.
On my installation of mamp there were multiple instances of the /conf directory with php.ini files. The php.ini files I needed were located in the /bin/php/php[version#]/conf directory and not the MAMP/conf directory.
Exact path to the php.ini file I needed to edit:
Applications/MAMP/bin/php/php5.4.10/conf/php.ini
Change display_errors = Off to display_errors = On
In addition to the display_errors directive, which has to be set to On, you might have to configure error_reporting.
For instance, you can use this in your php.ini file :
error_reporting = E_ALL
Another should, useful to test, might be to place this kind of portion of PHP code at the beginning of your script :
error_reporting(E_ALL);
ini_set('display_errors', 'On');
This is useful when you don't have access to php.ini and/or just want to test quickly, without having to restart the webserver.
As a sidenote, when it comes to displaying errors, the Xdebug extension is really great : when it's installed/enabled/configured, instead of just having an error message, you'll get the full stack-trace, which is much more useful ;-)
I recently experienced the same problem - in my case I had downloaded a client's Wordpress site from their live server that turned out to have been tampered with by malicious script insertion that was overriding the error reporting in order to escape detection.
A little late to help the OP(!), but perhaps of use to future searchers.
There might have a .htaccess file in a directory that overrides the display_errors setting set in php.ini. From your post I assume you didn't explicitly add this but a few frameworks do this by default so might be added that way. Look for a line like this in your .htaccess file:
php_value display_errors 0
and change the value to 1.
If you have several php sdks with several versions, first make it sure you are editing correct php.ini file. If you were right add this two lines at the beginning of the code.
error_reporting(E_ALL);
ini_set('display_errors', 'On'); // or ini_set('display_errors', 1);
Here's a twist to the same answer. I had the same issues, just copied and pasted the ini path from the php info page and still same problems...
turns out I made a syntax mistake when I edited my 'error_reporting' block in the php.ini.
I had E_NOTICE rather than ~E_NOTICE.
:(
So mistakes can happen in the php.ini if you were editing it and totally forgot you edited something.
I am trying to get my install of PHP under IIS to display errors, but I'm having no luck at all. I tried
error_reporting(E_ALL);
in the script, and nothing shows up, just a blank screen.
I tried editing my PHP.ini file and setting
error_reporting = E_ALL
display_errors = On
Also tried
error_reporting = E_ALL
display_errors = stdout
but nothing is showing up on the screen at all when my scripts throw errors.
Any advice?
Ensure that you're editing the PHP file in the correct location; IIS can look for a php.ini file in C:\WINDOWS rather than the install location of the PHP ISAPI or CGI module. Check the output of phpinfo(); to determine you're editing the correct php.ini file. Also, you need to restart the IIS service (or the computer overall) before those changes will be put into effect.
Sorry to resurrect a dead post but I had a similar issue and solved it by doing this in my PHP code:
ini_set('display_errors',1);
error_reporting(E_ALL);
This obviated the need to edit the server config and also allowed me to do this in just the method that I thought was problematic.
Perhaps IIS is blocking your errors from displaying.
Try:
Open inetmgr (Start -> Run -> inetmgr -> enter)
click on the site
select error pages (double click on it)
on the right hand side click on “Edit Feture Settings”
In the dialog that appears, select “Detailed Errors”.
Save and close.
Restart IIS just to be sure.
Posted for the sake of googlers like me.
on php.ini in the php installation path change the value of error display to on