I am using PHP (7.3.7) Non-ThreadSafe on IIS (windows) as FastCGI.
PHP installation is fresh and just php.ini-development renamed to php.ini thus error_reporting is set to E_ALL
running following script
<?php
echo "some text\n" ;
echo $aaaaaaa;
echo "another text\n" ;
?>
will generate output
PHP Notice: Undefined variable: aaaaaaa in ****\article.php on line 3
Note that first and 3rd lines are missing from output.
Using same installation of php, on apache (2.4.39) and nginx (1.17.2) (also on windows system) shows following output
some text
PHP Notice: Undefined variable: aaaaaaa in ****\article.php on line 3
another text
Is there an specific configuration that I need to change so PHP show same output as apache, nginx in IIS too?
or in other words, how can I configure my setup to show warning and notices and also the output of script.
I tried same script with PHP (7.1.30, 7.2.11, 5.2.10.10) and same issue still persists on IIS but not on apache or nginx.
Edit
I know that if I set error_reporting is set to E_ALL, all errors, warning and notices are shown and when I change it to E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED notices and warnings are disabled and won't show.
I also know that $aaaaaaa is not defined and it being there is for illustration of the issue.
Edit 2
It seems this has to do with configuration of fast-cgi on IIS. On same machine with same php installation and configuration using apache and nginx I can see exactly what Phil and sancoLgates shown in their links. I am editing my question to reflect the issue
In your code variable $aaaaaaa is not defined so define it first.
To check error add this code
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
// and then add your code below
?>
Related
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'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'm trying to hide a deprecated warning on a site and so I've added error_reporting(E_ALL ^ E_DEPRECATED); but it's not having any effect. I've got the following test running:
error_reporting(E_ALL ^ E_DEPRECATED);
var_dump(E_ALL ^ E_DEPRECATED, error_reporting());
And the var_dump is outputting int(24575) int(32759), as you can see error_reporting isn't being set. I've also tried error_reporting(24575); just in case, and that didn't do anything either.
I've checked ini_get('error_reporting'); and that also returns 32759. Using ini_set('error_reporting', E_ALL ^ E_DEPRECATED); also doesn't change the error level.
A little more info about the server: It's a VPS configured through WHM used for development purposes. This site is running on PHP 5.6 FPM. The server was upgraded this morning to Easy Apache 4 to enable PHP 7, though 5.6 was left as an option for older sites such as this one.
Does anyone know why error_reporting isn't changing the error level? I've tried googling this but all I get are questions on how to get errors to show or hide, nothing on why error_reporting isn't changing the error level.
Turns out it was PHP-FPM, apparently it doesn't allow you to modify the configuration variables directly. The only place it can be changed is in the config file for PHP-FPM. I've disabled FPM for this site and it's working fine now.
I am trying to get PHP errors to display on the screen using IIS vrs 8.5 and PHP vrs 5.2.17, but I continue to get the IIS 500 error http page, or a blank screen. I have already found numerous SO posts that have supposed fixes, but nothing on them has fixed my problem yet. Here is what I have tried.
Changed errorMode to Detailed. Still getting the 500 error page instead of the php error.
Removed all of the custom errors in the default IIS config file under the "httpErrors" block. Still getting the IIS custom 500 error page.
Added existingResponse="PassThrough" to my httpErrors block in the default IIS config. Doing this causes me to get a blank page instead of the php error, or the IIS 500 error.
I have verified that none of these settings are being overwritten in the site default system.config files.
Currently I am getting a blank page instead of the IIS 500 error on the screen. I have already verified that display_errors is on, and error_reporting is correct. I also know that the php page runs just fine. I am purposely causing this php error by removing a semi-colon on the page. So I already know everything is working fine. PHP Error logging is also working, but I want the errors to display on the page so I dont have to look at the error log every 5 minutes.
What else could be causing this?
IF you set custom error to Detailed in feature settings of error pages for website and server both
AND if in your php.ini file you set the display_errors = on & error_reporting = E_ALL
THEN there is only one possibility for getting [IIS default 500 error page] is that "Your PHP is not working coz of miss configuration."
The required configurations are:
After setting Handler Mappings to your php-cgi.exe file(which is in you php installation dir) as FastCGI, open the php.ini file and edit following lines OR add if not found in file. (if php.ini is not exists in you PHP installation dir then rename from existing php.ini-development OR php.ini-production)
1) extension_dir = "ext\"
;ext folder will be in PHP installation, if not create and don't forget ending \
2) log_errors = On
3) error_log = "C:\inetpub\temp\php-errors.log"
4) cgi.force_redirect = 0
; may be you need to add this line add it anywhere, for instance-before '; File Uploads ;'
5) cgi.fix_pathinfo = 1
6) fastcgi.impersonate = 1
7) fastcgi.logging = 0
Be careful and there should not `;` before any of these lines.
see documentation - installing/configuring PHP
Even after correct configurations PHP may not work because of system corruption. You can check by double click on php-cgi.exe and php-win.exe it should run without proper error (other then warnings OR ext/fileName... is missing messages - these are OK).
Note: after these many other setting are requires to run all things of php (ex. session), but by these SIMPLE PHP WILL WORK or PHP will properly show the error for what's wrong (NOT 500 page).
Make sure you are editing the right php.ini file. To check which file needs to be edited, go to IIS > Handler Mappings and look for PHP. Then check which directory they are located in.
In my case, I had two directories and was editing the wrong php.ini file, which was the reason why I was unable to get the errors to display.
I was having a similar issue getting a 500 error instead of a PHP error. I fixed the issue by going to PHP Manager within IIS
Under PHP Settings click configure error reporting. This will allow you to choose between Development and Production machine. If you choose Production you will get no detailed PHP errors in the browser, you will only get wrritten to a logfile. Development will allow for both errors to be displayed and written to a logfile.
I hope this helps.
If ou are Getting error 500 when active php to show errors, maybe you need to turn off the tracking error
Follow the step by step to fix.
If you don't have downnload the PHP Manager for IIS, you can find it in Web Platform Installer. Then open it.
After that click on manage all settings
Now Just turn off this setting
under server configuration feature view you see fast-cgi settings,
double click it. you see php-cgi.exe. double click it. set standart error mode to IgnoreAndReturn200.
regards
I was struggling with this issue - I have my PHP Handler Mapping set as follows, confirming I'm using PHP 5.3:
Therefore I then went to the corresponding location to find the correct file, here: C:\Program Files (x86)\PHP\v5.3 and edited php.ini
At first it looked like this:
; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
I changed it to this:
error_reporting(E_ALL);
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
I had to restart the Server in IIS to apply the change (choosing the Server from the list at the top on the left hand side, rather than selecting the Site on the left, lower down):
Now I see the error message - e.g.
Parse error: syntax error, unexpected '=' in C:\data\test.php on line 2
Instead of this type of generic error - e.g. on Chrome:
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