【问题标题】:I developed a wordpress plugin got an unusual error suddenly我开发的wordpress插件突然出现异常错误
【发布时间】:2021-02-11 20:38:06
【问题描述】:

我在 wordpress 中开发了一个自定义插件,它工作正常,但突然出现异常错误,如下所示

Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /public_html/demo2/wp-content/plugins/my-plugin-custom/inc/admin/Settings.php on line 7

这是第 7 行的内容

<?php
/**
 * @package My Custom Plugin
 */ 

namespace Inc\admin;

class Settings {
    public function register() {
        add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
    }
}

任何人都可以帮助我解决这个问题到底发生了什么我真的很困惑

【问题讨论】:

  • 如果命名空间没有问题,那么您可以尝试在&lt;?php 之后插入namespace Inc\admin; [可能是第二行]
  • 看看有没有leading space
  • @AkhtarujjamanShuvo 你能把这个作为对我有用的答案吗

标签: php wordpress


【解决方案1】:

如果命名空间没有问题,那么您可以尝试在&lt;?php 之后插入namespace Inc\admin; [可能是第二行]

【讨论】:

    【解决方案2】:

    我通过删除空格来修复它,谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-13
      • 2021-06-11
      相关资源
      最近更新 更多