使用 Jquery 删除页面顶部的 PHP 错误消息


Remove PHP Error Message at top of page with Jquery

我有一个站点在表达式引擎上运行。似乎网络服务器已升级,现在插件正在抛出错误消息。它似乎不会影响站点的运行,因此当我尝试解决此问题时,我认为可以使用jquery隐藏PHP错误消息。

错误消息被放在页面上,先于其他任何内容 -> 在 DOCTYPE 标记之前。

这是一行:

Strict Standards: Non-static method Foxee_utils::check_cache() should not be called statically, assuming $this from incompatible context in /home/noelwhit/public_html/admin/modules/foxee/mod.foxee.php on line 228

我以某种方式玩弄$(document).before(),但似乎离伟大还有一点点距离。

谢谢。

$(document).before()

这绝对不应该用jQuery修复。除了jQuery之外,至少有两种方法可以解决此问题:

  1. 艰难而正确的方式。Foxee_utils::check_cache()前缀static关键字:

    static function check_cache(/* skip */)
    
  2. 简单的方法。在站点配置文件中的某个位置添加,在其他调用之后error_reporting()如果有:

    error_reporting(error_reporting() & ~E_STRICT);
    

这是许多问题的重复。但这是你的答案

error_reporting(0)

在页面顶部


编辑:我强烈建议不要使用此答案,但如果您真的想破解自己的方式...用这个答案来帮助你。基本上,你采用你的内部html,然后重写你的页面。但你应该真诚地尝试解决你的问题,而不是隐藏它......社区在这里为您提供帮助,充分利用它。

以下是他的回答片段:

var markup= document.documentElement.innerHTML;
markup= '<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'+markup+'</html>';
document.open();
document.write(markup);
document.close();