抑制来自odbc_connect调用的PHP错误 [英] Suppress PHP error from a odbc_connect call

查看:64
本文介绍了抑制来自odbc_connect调用的PHP错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我故意使用错误信息进行了odbc_connect调用,如下所示:

Let's say I do a odbc_connect call, deliberately using erroneous information, as follows:

<?PHP odbc_connect('bogus','bogus','bogus'); ?>

现在,手册指出odbc_connect"[r]错误时返回ODBC连接ID或0(FALSE)".我可以返回0,但可以运行文件(使用 Wampserver ),我还会收到错误消息,告诉我出了点问题.

Now, the manual states that odbc_connect "[r]eturns an ODBC connection id or 0 (FALSE) on error". I'm okay with the 0 being returned, but when I'm running the file (using Wampserver), I also receive error messages telling me that something went wrong.

我想隐藏此错误消息,因为我正在尝试构建PHP文件仅在数据库调用信息错误时回显某些文本,例如不成功".

I would like to suppress this error message, since I'm trying to build a PHP file that only echoes a certain piece of text, like "unsuccessful", when the information for the database call was wrong.

推荐答案

您可以使用错误抑制运算符@.

You can use the error-suppression operator @.

<?php
    $conn = @odbc_connect('bogus','bogus','bogus');
?>

这篇关于抑制来自odbc_connect调用的PHP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆