PHP script showing a blank screen
I have a server setup where a test script with just phpinfo() works fine.
When I try to run my application on it, it shows up as a blank screen.
I am calling index.php from the browser. The first few lines are as:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once('codelibrary...
Yet, the screen continues to be blank.
Edit 1
Here's the structure of the files:
/.htaccess
/index.php
/codelibrary/inc/user-top.php
/codelibrary/inc/variables.php
/codelibrary/inc/config.php
index.php
<?php
require_once('codelibrary/inc/user-top.php');
...
/codelibrary/inc/user-top.php
<?php
require_once("./codelibrary/inc/variables.php");
...
/codelibrary/inc/variables.php
<?php
include_once('config.php');
...
I thought the referencing here might be a problem, so I changed it to:
require_once("./codelibrary/inc/config.php");
as well, but no luck.
Edit 2
Ah ha! Thanks Col and TopQ for pointing out that I should look at the log file, it says:
[10-Sep-2010 17:06:02] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/suhosin.so' - /usr/local/lib/php/extensions/no-de开发者_如何转开发bug-non-zts-20090626/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0
Try setting display_errors from a .htaccess
file
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
Use "view source" in your browser to see if anything is being written by your script that the browser might not be rendering visibly.
EDIT
If you're getting an http 500 response, then you can always do a php lint check on your script from the command line:
php -l <filename.php>
An extremely useful and oft-forgotten check on the syntax of your code.
Check the PHP error log. Usually syntax error or missing dependencies.
The problem is possibly the following: The error occurrs before your script runs (i.e. while parsing. Probably some syntax error). Since your script does not run, the error-level cannot be changed dynamically. You need to set error_reporting
in your php.ini
, or try fire's suggestion, which should produce equivalent results.
As noted in the other answers here if there is an error present in your script it will fail to set the error levels dynamically.
You can add the proper directives to either the .htaccess file in the current directory, the webserver config or the php.ini file (http://php.net/manual/en/errorfunc.configuration.php). You need to prefix those with the php_flag directive a la php_flag display_errors on
.
If you can't add the commands to the .htaccess files it is most probable that your server config does not allow for overrides for those properties. Consult with the server maintainer for either changing these values, allowing you to override these directives on a per-folder basis and having access to error logs for your virtual hosts.
Considering that this is a script that will be executed by a user outside of your group (the browser/webserver) i would think that the file should be set with permissions 755 as this allows the you to make changes and noone else yet ensures that the browser can execute the script (755 -> -rwxr-xr-x)
精彩评论