php文件运行后屏幕空白,为什么php文件空白

Why is my PHP page blank?

If a PHP page is entirely blank, it almost certainly means there is an error in your PHP code, and that the display_errors directive in your web server is turned off. Most hosting companies these days turn off display_errors as a security measure, because error messages can reveal vulnerabilities to a malicious attacker. However, you should always test PHP pages first in a safe development environment on your local computer or network.

In a local testing environment, the display_errors directive should be turned on. If you have used an all-in-one package to install PHP/MySQL, the package's control panel might have an option to turn on the display of errors. If not, you need to edit php.ini, the configuration file that is normally located in the main PHP folder.

Scroll down to the Error handling and logging section. For a development environment, you should use the following settings:

; Default Value: E_ALL & ~E_NOTICE

; Development Value: E_ALL | E_STRICT

; Production Value: E_ALL & ~E_DEPRECATED

;http://php.net/error-reporting

error_reporting = E_ALL | E_STRICT

; This directive controls whether or not and where PHP will output errors,

; notices and warnings too. Error output is very useful during development, but

; it could be very dangerous in production environments. Depending on the code

; which is triggering the error, sensitive information could potentially leak

; out of your application such as database usernames and passwords or worse.

; It's recommended that errors be logged on production servers rather than

; having the errors sent to STDOUT.

; Possible Values:

;   Off = Do not display any errors

;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)

;   On or stdout = Display errors to STDOUT

; Default Value: On

; Development Value: On

; Production Value: Off

;http://php.net/display-errors

display_errors = On

This extract from php.ini is taken from the version in PHP 5.3. Your version of php.ini might look slightly different, but the values for the directives should be the same.

After saving php.ini, restart your web server for the changes to take effect.

Turning on the display of errors temporarily on a live server

Sometimes, you might need to turn on the display of errors temporarily if something goes wrong with a script on your remote server. Add the following code at the very top of the script:

When you reload the page, this should display any error message. When you have fixed the problem, remove this line of code.

NOTE: this technique does not work if your page contains a syntax (parse) error, such as a missing semicolon, or an unmatched quote or parenthesis. It is, however, useful for displaying warning about missing include files.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值