sanhutrees 发表于 2018-12-9 07:02:50

让iis7.5显示php错误的详细信息~

这两天在win7下调试php程序, 用的是fastcgi模式的,也不知这个模式到底怎么样, 但既然win7和win2008都默认支持这个模式, 那就应该是不错的, 而且php5.3以上版本也在win7下也只支持这个模式,
u.php   // 写一个明显的错误程序来测试;
{
phpinfo()abc;
}
在这样的环境下调试, 出错了一些错误, 包括现在所面对的问题, 调试程序时报不出详细错误! 在ii7的fastcgi模式下只提示如下错误:
错误摘要
HTTP 错误 500.0 - Internal Server Error
无法显示页面,因为发生内部服务器错误。 详细错误信息
模块 FastCgiModule
通知 ExecuteRequestHandler
处理程序 PHP_via_FastCGI
错误代码 0x00000000
请求的 URL http://localhost:80/u.php
物理路径 C:\inetpub\wwwroot\u.php
登录方法 匿名
登录用户 匿名


其实,这样的报错信息对于调试程序只有一点儿用处, 那就是程序你写错了! 其它就没有信息了, 如果调试一个几百行代码的php程序就很棘手
在网上查了很久, 更改php.ini的log_errors =Off的选项 为On , 还是报上面的错误, 但是能到
error_log="C:\windows\temp\php-errors.log"
这个目录文件下看到相关错误详细信息 ! 但是这样也很麻烦, 你不可能一出错就去查看这个日志文件吧!
如何让错误信息直接显示到IE浏览器里面就个问题了, 在公司同事的帮助下才解决了这个问题!
将php.ini下文件 display_errors = Off更改为 display_errors = On就可以了, 就会显示如下错误信息:
Warning:Unknown: It is not safe to rely on the system's timezone settings. Youare *required* to use the date.timezone setting or thedate_default_timezone_set() function. In case you used any of thosemethods and you are still getting this warning, you most likelymisspelled the timezone identifier. We selected 'UTC' for '8.0/no DST'instead in C:\inetpub\wwwroot\u.php on line 2 Parse error: syntax error,unexpected T_STRING in C:\inetpub\wwwroot\u.php on line 2


其实上面的错误信息里面 Parse error: syntax error, unexpected T_STRING in C:\inetpub\wwwroot\u.php on line 2 才是有用的错误信息!
至于:
Warning:Unknown: It is not safe to rely on the system's timezone settings. Youare *required* to use the date.timezone setting or thedate_default_timezone_set() function. In case you used any of thosemethods and you are still getting this warning, you most likelymisspelled the timezone identifier. We selected 'UTC' for '8.0/no DST'instead in C:\inetpub\wwwroot\u.php on line 2
这样的错误的信息, 是时区不一致导致的, 每次都出现这样的错误信息也不必, 那就改时区设置吧!
如果是中国大陆就将php.ini的 ;date.timezone = 更改为 date.timezone = PRC
就可以了! 记住更改这个设置一定要iisreset重启一下iis才行!
出错信息如下: Parse error: syntax error, unexpected T_STRING in C:\inetpub\wwwroot\u.php on line 2

好了, 现在就完整调试完毕了, 如果以的一再有程序错误就容易找到程序错误的具体位置了!




页: [1]
查看完整版本: 让iis7.5显示php错误的详细信息~