🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# $errno ## $errno 错误号,为 0 时,表示正常,非 0 时表示错误。 在某些函数被调用后发生错误,该全局变量会被设置,有点类似于 Linux C 的 errno 。 因为 PHP 是同步的(区别于异步)并且线程安全的,所以使用这种方法来返回错误会很方便。 一般配合 errstr 一起使用,函数内通过 xn\_error($errno, $errstr) 设置错误。 相比起抛出异常来,这种处理方式会轻量级很多。 【定义】 文件:xiunophp/xiunophp.php 大约 58 行: ``` <pre class="calibre11">``` $errno = 0; ``` ``` 【用例】 ``` <pre class="calibre11">``` <?php include './xiunophp/xiunophp.php'; include './xiunophp/xn_send_mail.php'; $r = xn_send_mail(array(), 'username', 'test@gmail.com', '标题', '内容'); if($r === FALSE) { echo "Errno:".$errno.", Errstr:".$errstr; } ?> ``` ``` 【相关函数】 xn\_error()