php错误

log_errors = On  //打开错误日志

display_errors = On  //将错误显示在php页面好

error_reporting = E_ERROR  //定义出错级别   //;error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING & ~E_STRICT

[root@web_dev test.com]# cat index.php

index.html
如果页面有致命错误那么显示在页面上,如果只是警告那么通过代码中添加error_reporting(E_ALL)来显示
<pre>
[root@web_dev test.com]# cat /app/php5/lib/php.ini |grep --color -B 20 "display_errors = On"
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
;error_reporting = E_ALL
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING & ~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
</pre>
<?php
//error_reporting(E_ALL);
ini_set("error_reporting", E_ALL);
//$mobile = isset($_GET['mobile'] ) ? $_GET['mobile'] : '';
$mobile = $_GET['mobile'];
echo "mobile=>".$mobile;
echo "<br>";
$uid = $_GET['uid'];
echo "uid=>".$uid;
echo "<br>";
$fp=fopen("csa.txt","r");
?>

index.html 如果页面有致命错误那么显示在页面上,如果只是警告那么通过代码中添加error_reporting(E_ALL)来显示

[root@web_dev test.com]# cat /app/php5/lib/php.ini |grep --color -B 20 "display_errors = On"
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
;error_reporting = E_ALL
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING & ~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

Notice: Undefined index: mobile in /home/yansiyu/test.com/index.php on line 31 mobile=>
Notice: Undefined index: uid in /home/yansiyu/test.com/index.php on line 34 uid=>
Warning: fopen(csa.txt): failed to open stream: No such file or directory in /home/yansiyu/test.com/index.php on line 37

    A+
发布日期:2017年12月21日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: