如何配置 PHP 显示详细错误而不是错误 500 页面?
我在 IIS 托管上部署了一个 PHP 应用程序,并且总是收到通用 IIS“错误 500”页面,而不是详细的错误页面。
我知道我需要修改一些 php.ini 文件(来自 这个问题)。
看来 display_errors 设置正确:
echo ini_get('display_errors');
输出 1
。
我还尝试在导致错误的函数中设置 display_errors 和 error_reporting (我知道特定函数是问题所在,因为我手动修改了它)。
function sendEmail( $aForm, $sFile = 'messages.tpl', $sTargetEmail = null ){
error_reporting(E_ALL);
ini_set('display_errors', 'On');
//rest of the function
编辑:我知道我应该在某些 php.ini 文件中设置这些值 - 当我只能通过 FTP 访问我的应用程序文件夹时,如何在共享主机上指定 php.ini 值?
如何识别错误详细信息?
I have a PHP application deployed on my IIS hosting and I am always getting generic IIS "error 500" pages insteady of detailed error pages.
I understand I need to modify some php.ini file (from this question).
It seems that display_errors is set correctly:
echo ini_get('display_errors');
outputs 1
.
I have also tried setting display_errors and error_reporting in the function that causes the error (I know the particular function is the problem because I manually modified it).
function sendEmail( $aForm, $sFile = 'messages.tpl', $sTargetEmail = null ){
error_reporting(E_ALL);
ini_set('display_errors', 'On');
//rest of the function
EDIT: I know I should have set these values in some php.ini file - how can I specify php.ini values on a shared hosting, when I have only access to my app folder via FTP?
How can I identify the error details?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您确实打开了“display_errors”,但您的托管提供商将您的 500 错误页面重定向到不显示错误的自定义页面。设置不是很好,但我会联系您的托管提供商,希望他们能够解决这个问题。可以让 IIS 上的 .user.ini 文件看到
请参阅http://learn.iis.net/page.aspx/745/enable-per-site-php-configuration-on-iis-60-and-iis-7-and-above/
同样,只有您的托管提供商会知道是否已设置。
It looks to me like you do have 'display_errors' turned on but your hosting provider is redirecting your 500 error page to a custom page which doesn't display the errors. Not a great set up but I would contact your hosting provider in the hope that they can shed some light on the problem. It is possible to have .user.ini files on IIS see
see http://learn.iis.net/page.aspx/745/enable-per-site-php-configuration-on-iis-60-and-iis-7-and-above/
again only your hosting provider would know if this is set up.