PHP 抛出的错误消息与我想要的不同
我有一个 Javascript 函数,它在我的服务器上调用 PHP 脚本。如果发生故障,JS 函数期望从脚本接收 save_failed
消息。
出于测试目的,我在下面的行中放入了错误的数据库信息,因此它失败了:
mysql_connect("hostname", "user", "pass") or die('save_failed');
但是,JS 函数的行为不符合预期,并且似乎没有收到 save_failed
作为输出。为了确认,我将收到的消息显示为警报框,这就是我得到的。
为什么 php 脚本不抛出 save_failed
以及如何让它这样做?
I have a Javascript function which calls a PHP script on my server. In case of failures, the JS function is expecting to receive a message of save_failed
from the script.
For testing purposes, I put the wrong database info in the line below so that it fails:
mysql_connect("hostname", "user", "pass") or die('save_failed');
However, the JS function was not behaving as expected, and it seemed it wasn't receiving save_failed
as the output. To confirm, I displayed the message being received as an alert box and this is what I got.
Why is the php script not throwing just save_failed
and how can I make it do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经安装了 Xdebug,并且正在发生更多错误。
在生产中,您应该有
error_reporting(0)
和ini_set('display_errors', “0”)
。You have Xdebug installed and further errors are occurring.
In production, you should have
error_reporting(0)
andini_set('display_errors', '0')
.