Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何禁用所有Drupal 7错误和异常处理程序_Php_Drupal_Drupal 7 - Fatal编程技术网

Php 如何禁用所有Drupal 7错误和异常处理程序

Php 如何禁用所有Drupal 7错误和异常处理程序,php,drupal,drupal-7,Php,Drupal,Drupal 7,我想在Drupal网站的根目录下创建一个简单的PHP状态文件。此文件将由Nagios等监控系统调用。我想完全自定义输出,并在错误消息中添加一些额外的细节(作为纯文本字符串) 我尝试了以下代码: define('DRUPAL_ROOT', __DIR__); require_once realpath(DRUPAL_ROOT . '/includes/bootstrap.inc'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); restore_excepti

我想在Drupal网站的根目录下创建一个简单的PHP状态文件。此文件将由Nagios等监控系统调用。我想完全自定义输出,并在错误消息中添加一些额外的细节(作为纯文本字符串)

我尝试了以下代码:

define('DRUPAL_ROOT', __DIR__);
require_once realpath(DRUPAL_ROOT . '/includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

restore_exception_handler();
restore_error_handler();

function exception_handler($exception) {
  echo "Uncaught exception: " , $exception->getMessage(), "\n";
}
set_exception_handler('exception_handler');

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
  echo "PHP Error: [$errno] $errstr<br />\n";
  return true;
}
$old_error_handler = set_error_handler("myErrorHandler");

try {
  db_query('SELECT COUNT(nid) FROM {node}');
  echo 'ok';
}
catch (\PDOException $e) {
  echo "Database problem";
}
catch (Exception $e) {
  echo "Unexecpted error: " . $e->getMessage();
}
define('DRUPAL\u ROOT',\uuuuuuu DIR\uuuuu);
需要_once realpath(DRUPAL_ROOT./includes/bootstrap.inc');
drupal\u引导(drupal\u引导\u完全);
还原异常处理程序();
还原错误处理程序();
函数异常处理程序($exception){
回显“未捕获异常:”,$exception->getMessage(),“\n”;
}
设置异常处理程序(“异常处理程序”);
函数myErrorHandler($errno、$errstr、$errfile、$errline)
{
echo“PHP错误:[$errno]$errstr
\n”; 返回true; } $old_error_handler=set_error_handler(“myErrorHandler”); 试一试{ db_查询('从{node}选择计数(nid)); 回声‘ok’; } 捕获(\p异常$e){ 回声“数据库问题”; } 捕获(例外$e){ 回显“未排除的错误:”..e->getMessage(); }

但是,当我尝试禁用数据库(通过停止服务)时,会以HTML格式显示Drupal自定义错误。

您必须转到
admin/config/development/logging
并选中
None
选项以隐藏错误