ikkhksvu 发表于 2024-10-4 12:13:32

WordPress遇到PHP致命错误的处理办法Call to undefined function


    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/ef12092e070d4bf5bf2a6c40e757f1f9~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728206453&amp;x-signature=TaEIK2Z8tkLPYJA%2FOcd9qRhUpVU%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">搬主题在进行站点<span style="color: black;">守护</span>WordPress站点的时候<span style="color: black;">发掘</span>日志中经常<span style="color: black;">显现</span>一个错误:PHP Fatal error: Uncaught Error: Call to undefined function get_header().....等,<span style="color: black;">亦</span><span style="color: black;">便是</span>php的致命错误。直接翻译<span style="color: black;">便是</span><span style="color: black;">拜访</span>时得到调用未定义函数的错误。<span style="color: black;">怎样</span>进行<span style="color: black;">处理</span>及修复呢?<span style="color: black;">这儿</span>搬主题就给<span style="color: black;">大众</span>分享一下<span style="color: black;">处理</span><span style="color: black;">方法</span>。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">原文链接:<a style="color: black;">WordPress遇到PHP致命错误的<span style="color: black;">处理</span>办法“PHP Fatal error: Uncaught Error: Call to undefined function get_header()” - 搬主题</a></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">什么是调用未定义函数错误?</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这是一个直接针对主题的致命错误,<span style="color: black;">亦</span><span style="color: black;">便是</span>你安装了WordPress主题的话,<span style="color: black;">她们</span>会收到一个指向你的主题目录的URL。好吧,有<span style="color: black;">非常多</span><span style="color: black;">办法</span><span style="color: black;">能够</span><span style="color: black;">得到</span>这些信息。让我用一个例子来解释。大<span style="color: black;">都数</span>主题<span style="color: black;">包含</span>JavaScript文件、CSS和URL的链接。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">垃圾爬虫<span style="color: black;">或</span>黑客会向流行的WordPress主题文件如index.php或header.php发送请求。<span style="color: black;">这般</span>一来,请求文件就会将安全隐患<span style="color: black;">泄密</span>,这是一个<span style="color: black;">重点</span>的攻击。这<span style="color: black;">亦</span><span style="color: black;">诱发</span>了调用未定义函数错误。<span style="color: black;">例如</span><span style="color: black;">非常多</span>时候<span style="color: black;">有些</span>黑客直接攻击你的wp-login.php文件,当然你<span style="color: black;">实质</span><span style="color: black;">亦</span><span style="color: black;">能够</span><span style="color: black;">容易</span>地修复它。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">换句话说,你<span style="color: black;">能够</span>说当一个用户请求header.php文件时,任何重要的函数如exc_url()都是不可用的,<span style="color: black;">由于</span>它是在WordPress之外。<span style="color: black;">或</span>这种<span style="color: black;">状况</span>的<span style="color: black;">出现</span>是<span style="color: black;">由于</span>WordPress核心<span style="color: black;">无</span>被加载,加载的是模板文件。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这可能是<span style="color: black;">因为</span>垃圾爬虫和取决于你的主题,它是<span style="color: black;">怎样</span>编码的,这可能是<span style="color: black;">因为</span><span style="color: black;">欠好</span>的操作或脱离上下文执行的代码。</p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">检测</span>网站<span style="color: black;">是不是</span>受到攻击?</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">首要</span>,你需要<span style="color: black;">检测</span>你的网站<span style="color: black;">是不是</span>有受到攻击。要<span style="color: black;">检测</span>这个错误,请看错误日志。<span style="color: black;">例如</span>说。<span style="color: black;">发掘</span>的错误类似如下</p> PHP Fatal error: Uncaught <span style="color: black;">Error</span>: Call to <span style="color: black;">undefined</span> <span style="color: black;"><span style="color: black;">function</span> <span style="color: black;">get_header</span>() <span style="color: black;">in</span> /<span style="color: black;">www</span>/<span style="color: black;">www</span>.<span style="color: black;">banzhuti</span>.<span style="color: black;">com</span>/<span style="color: black;">wwwroot</span>/<span style="color: black;">wp</span>-<span style="color: black;">content</span>/<span style="color: black;">themes</span>/<span style="color: black;">qux</span>/<span style="color: black;">index</span>.<span style="color: black;">php</span>:2</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>你的网站<span style="color: black;">显现</span>这种类型的错误,这<span style="color: black;">寓意</span>着你的网站被垃圾爬虫或黑客盯上或攻击了。你<span style="color: black;">能够</span>看到<span style="color: black;">非常多</span>类型的这类错误。在这个例子中,你<span style="color: black;">能够</span>看到index.php,404.php,和header.php。经过<span style="color: black;">科研</span>和从<span style="color: black;">源自</span>得到的评论,<span style="color: black;">非常多</span>人在WordPress文件中看到这种错误,而不是例子。</p>查看这些: /archive.php/Wp-includes/rss-functions.php...<span style="color: black;">各样</span>主题模板文件...WP<span style="color: black;">媒介</span>库中的<span style="color: black;">各样</span>文件<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">从<span style="color: black;">基本</span>上说,从WordPress核心、插件或文件的直接<span style="color: black;">拜访</span>会触发一个错误。为<span style="color: black;">认识</span>决这个问题,<span style="color: black;">咱们</span>分享<span style="color: black;">认识</span>决调用未定义函数错误的<span style="color: black;">办法</span>,以<span style="color: black;">加强</span>你的主题的整体安全性。</p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">问题出在哪里?</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">- <span style="color: black;">倘若</span>你试图登录到你的WordPress账户。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">- <span style="color: black;">倘若</span>你<span style="color: black;">已然</span>更新了WordPress。</p>- <span style="color: black;">倘若</span>你收到这个信息;is_network_admin()错误信息或 "致命错误,未定义函数is_network_admin()"
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">怎样</span>修复调用未定义函数的致命错误?</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">处理</span>这种类型的错误的一个最有效和最简单的<span style="color: black;">办法</span>是,<span style="color: black;">倘若</span>WordPress不可用,就退出该脚本。这是一个有效的、众所周知的<span style="color: black;">处理</span>这个问题的技术。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">换句话说,<span style="color: black;">倘若</span>ABSPATH常数不是确定的,就退出脚本。ABSPATH在WordPress被加载时起<span style="color: black;">功效</span>。当垃圾爬虫来请求一个主题模板时,它就会给出一个空白页。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">例如</span>说:</p><span style="color: black;"><span style="color: black;">&lt;?</span> php <span style="color: black;">if</span> (!defined (‘ABSPATH’) <span style="color: black;">exit</span> ;<span style="color: black;">?&gt;</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">你在WordPress会话<span style="color: black;">时期</span>看到过<span style="color: black;">这般</span>的代码。<span style="color: black;">守护</span>直接脚本<span style="color: black;">拜访</span>的PHP安全是至关重要的。毕竟,你不需要网站上的爬虫/攻击者。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">因此</span>,要退出脚本,你需要<span style="color: black;">根据</span>给定的方式。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">首要</span>打开任何你自己的WordPress主题文件,<span style="color: black;">而后</span>在文件的顶部<span style="color: black;">包含</span>给定的一行。当你<span style="color: black;">没法</span><span style="color: black;">拜访</span>或退出脚本时,你会看到给定的代码。</p><span style="color: black;"><span style="color: black;">&lt;?</span> php
      <span style="color: black;">if</span> (!defined(<span style="color: black;">ABSPATH</span>)) <span style="color: black;">exit</span>;
      get_header();
      <span style="color: black;">?&gt;</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">如下效果</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/e31565d6e7824f92adfa3460b33b345a~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728206453&amp;x-signature=xe68ShI5rLzocN2ra%2B6g0JQ67uw%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">进阶<span style="color: black;">守护</span></h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">为了进一步发展,你<span style="color: black;">能够</span><span style="color: black;">经过</span>限制目录视图来<span style="color: black;">守护</span>重要文件。让<span style="color: black;">咱们</span><span style="color: black;">思虑</span>一个例子:当你<span style="color: black;">经过</span>浏览器<span style="color: black;">拜访</span>父目录时,你<span style="color: black;">是不是</span>启用了目录视图。<span style="color: black;">倘若</span>是的话,你会得到一个链接的文件列表,这不是好事。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">要么你看到一个空白的屏幕,<span style="color: black;">亦</span>许是<span style="color: black;">有些</span>其他的信息。你将需要保持你的文件安全。为了限制目录视图,你将需要创建<span style="color: black;">第1</span>个空文件index.php文件,以你想禁用的为准。</p>要禁止该代码,请<span style="color: black;">这般</span>做。
    &lt;!–?php <span style="color: black;">//</span> Silence <span style="color: black;">is</span>golden.&lt;/p&gt;
    &lt;p&gt;WordPress<span style="color: black;">运用</span>这种技术<span style="color: black;">已然</span>很<span style="color: black;">长期</span>了,以防止黑客/攻击者。<span style="color: black;">倘若</span>你在<span style="color: black;">拜访</span>WordPress时遇到任何麻烦,你应该试试这个。&lt;/p&gt;<h1 style="color: black; text-align: left; margin-bottom: 10px;">最后总结</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">正如你所看到的,<span style="color: black;">这儿</span><span style="color: black;">已然</span>分享了一个简单而有效的<span style="color: black;">办法</span>来防止网页被攻击者/黑客攻击。在这个技术中,<span style="color: black;">不消</span>太专业的能力,<span style="color: black;">倘若</span>你还是不清楚,<span style="color: black;">那样</span>添加一个合适的插件,以<span style="color: black;">得到</span>更好的安全性。</p>




wrjc1hod 发表于 2024-10-11 00:02:45

期待你更多的精彩评论,一起交流学习。
页: [1]
查看完整版本: WordPress遇到PHP致命错误的处理办法Call to undefined function