问题
I have browsed several other questions, and tried various solutions related to error reporting, including
ini_set('display_errors',true);
error_reporting(E_ALL);
but I am still stuck with the white screen of death. This seems to happen only on pages when I use my own object oriented classes. However, the OOP scripts execute successfully, but I am unable to get the HTML to show. Occasionally, I can get it to catch an Exception but it is intermittent.
For example, I have a this method:
public function getSubdomain() {
$this->data->query('SELECT * FROM users WHERE email=:email');
$this->data->bind(':email', $this->email);
$this->data->execute();
if($this->data->rowCount() == 0)
throw new Exception('There is no account associated with this e-mail address.');
$curr = $this->data->single();
return $curr['subdomain'];
}
^^ That will execute just fine and I can get it to print from the OOP class using die($curr['subdomain']);, but if I try displaying it on a page using PHP, nothing. No errors, so logs, no source code, absolutely nothing.
I am using MultiViews with Apache, and my DB queries are done using a custom PDO class.
I have run
# php -l new.php
directly on the server and it reports
No syntax errors detected in new.php
When I run the exact same setup on WAMP locally, it works without a problem, but once I migrated over to my CentOS/Apache/PHP machine, all hell broke loose. MySQL is on a seperate server, but has no problems.
I can provide much more specific code (both my own and conf files from the server) as needed, I just want to avoid anything arbitrary due to the nature of the question. Any suggestions on where to go from here (ie, different methods of error reporting, etc.)?
回答1:
Most times, when errors appear when we move from WAMP to LAMP it's a question of case sensitivity. Since windows is not CS but Linux is a lot can break.
I would:
- Check case on the classes / pages that are acting up
- Check .htaccess rules (or temporally remove them) to check the absence of errors
回答2:
I've also encountered PHP's white screen of death a few times. In my experience one of the most helpful things you can do is ensure PHP is logging to file using the error_log directive in php.ini: http://us1.php.net/manual/en/errorfunc.configuration.php#ini.error-log
If you're still not seeing any useful information in the PHP error log you've defined, or in the Apache error log, it might be time to add debug output through your code to identify the point at which the fatal error occurs. To do that you can either open a file handle and write to it yourself periodically, or just use the error_log() function to output debug messages.
来源:https://stackoverflow.com/questions/19626013/php-white-screen-of-death