Parse errors are not displayed

2019-01-26 03:34发布

I want PHP to display parse errors on screen. What I get instead is a blank page. Nothing gets written to server's error log file.

My setup: PHP5.2.9/IIS 6 (not Apache!).

My PHP.INI:

error_reporting=E_STRICT
display_errors = On
display_startup_errors = On
log_errors = On
error_log = "C:\Program Files\Zend\ZendServer\logs\php_error.log"

How do I get parse or fatal errors to be either logged or shown on screen?

Thanks, Temuri

UPDATE: After playing with different switches it looks to be an IIS specific problem. ANY IDEAS FOLKS?

8条回答
相关推荐>>
2楼-- · 2019-01-26 03:51

Apache doesn't always like to report parsing errors either. From the command line, run

php -l <file>

The -l switch tells PHP to check file syntax. See the man page.

查看更多
女痞
3楼-- · 2019-01-26 03:56

Re: Blank screen of php death death, I discovered that setting

php_value error_reporting "E_ALL" or php_value error_reporting 8192

in .htaccess on my Windows 7, Wampserver w/ apache 2.2.4 and php 5.3.13 are sure ways to get the blank php error screen -- today, June 3, 2014. These htaccess lines DO set the desires value in phpinfo(), but the display of the errors happens only when the line is commented out (not used) in htaccess.

BUT... the next minute I discover that

php_value error_reporting 8191

DOES set the phpinfo() value AND also allows display of the error messages to the browser! D'oh! It must be an integer and also apparently a particular or valid integer, and not just a large enough integer!

查看更多
▲ chillily
4楼-- · 2019-01-26 04:00

If you're using Zend Framework (v1) and you're using the Autoloader, the following code will prevent parse errors from being displayed:

self::$Autoloader->suppressNotFoundWarnings(true);

See the following answer for more details:

Display php errors when using Zend framework

查看更多
Viruses.
5楼-- · 2019-01-26 04:01

You can verify the script syntax with this command in terminal:

php -l path/to/file.php

Personally, I added this line to my ~/.bash_profile file so I can easily run php -l on all files in the current working directory:

phpl() { for i in *.php; do php -l $i; done }

If you're really hardcore, you can even run your app from the command line. You'll have a much better chance of seeing compile-time errors, and it's just kinda cool.

You can use the $argv variable to get the first argument, $argv[1], then use that as the request.

<?php
// show those errors!
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

// simulate a web server request
$request = '/' . isset($argv[1]) ? ltrim($argv[1], '/') : '/';
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'] = $request;

Then you can run your script via command line. This would be the equivalent of visiting: your-webapp.com/request/uri/here

php /path/to/script.php request/uri/here

Here is a more comprehensive example for running CodeIgniter via command line. It should work for many other frameworks too: http://phpstarter.net/2008/12/run-codeigniter-from-the-command-line-ssh/

查看更多
SAY GOODBYE
6楼-- · 2019-01-26 04:02

As Rasmus Lerdorf suggests, always use error_reporting(-1) on development server.

查看更多
欢心
7楼-- · 2019-01-26 04:07

Try this.

error_reporting(E_ALL);
ini_set("display_errors", 1);
查看更多
登录 后发表回答