<small id='vzu3p'></small><noframes id='vzu3p'>

    <bdo id='vzu3p'></bdo><ul id='vzu3p'></ul>

  • <legend id='vzu3p'><style id='vzu3p'><dir id='vzu3p'><q id='vzu3p'></q></dir></style></legend>
    <i id='vzu3p'><tr id='vzu3p'><dt id='vzu3p'><q id='vzu3p'><span id='vzu3p'><b id='vzu3p'><form id='vzu3p'><ins id='vzu3p'></ins><ul id='vzu3p'></ul><sub id='vzu3p'></sub></form><legend id='vzu3p'></legend><bdo id='vzu3p'><pre id='vzu3p'><center id='vzu3p'></center></pre></bdo></b><th id='vzu3p'></th></span></q></dt></tr></i><div id='vzu3p'><tfoot id='vzu3p'></tfoot><dl id='vzu3p'><fieldset id='vzu3p'></fieldset></dl></div>
  • <tfoot id='vzu3p'></tfoot>

        在函数内部使用 php 命名空间

        时间:2024-05-11
          <tfoot id='Ia5kV'></tfoot>
            • <bdo id='Ia5kV'></bdo><ul id='Ia5kV'></ul>
              • <i id='Ia5kV'><tr id='Ia5kV'><dt id='Ia5kV'><q id='Ia5kV'><span id='Ia5kV'><b id='Ia5kV'><form id='Ia5kV'><ins id='Ia5kV'></ins><ul id='Ia5kV'></ul><sub id='Ia5kV'></sub></form><legend id='Ia5kV'></legend><bdo id='Ia5kV'><pre id='Ia5kV'><center id='Ia5kV'></center></pre></bdo></b><th id='Ia5kV'></th></span></q></dt></tr></i><div id='Ia5kV'><tfoot id='Ia5kV'></tfoot><dl id='Ia5kV'><fieldset id='Ia5kV'></fieldset></dl></div>
                <legend id='Ia5kV'><style id='Ia5kV'><dir id='Ia5kV'><q id='Ia5kV'></q></dir></style></legend>

              • <small id='Ia5kV'></small><noframes id='Ia5kV'>

                    <tbody id='Ia5kV'></tbody>
                  本文介绍了在函数内部使用 php 命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  尝试在我自己的函数中使用名称空间时出现解析错误

                  I get a parse error when trying to use a name space inside my own function

                  require('/var/load.php');
                  
                  function go(){
                  
                    use testClass;
                  
                      $go = 'ok';
                      return $go;
                  }
                  
                      echo go();
                  

                  推荐答案

                  来自 导入范围规则

                  use 关键字必须声明在文件的最外层范围内(全局范围)或内部命名空间声明.这是因为导入是在编译时而不是运行时完成的,所以它不能块作用域

                  The use keyword must be declared in the outermost scope of a file (the global scope) or inside namespace declarations. This is because the importing is done at compile time and not runtime, so it cannot be block scoped

                  所以你应该这样说,应该在全局级别指定使用

                  So you should put like this, use should specified at the global level

                  require('/var/load.php');
                  use testClass;
                  
                  function go(){
                      $go = 'ok';
                      return $go;
                  }
                  echo go();
                  

                  查看以下手册中的示例 5请参阅其手册 http://php.net/manual/en/language.namespaces.importing.php

                  Check the example 5 in the below manual Please refer to its manual at http://php.net/manual/en/language.namespaces.importing.php

                  这篇关于在函数内部使用 php 命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:尝试使用作曲家时意外的“使用"(T_USE) 下一篇:PHP 命名空间和内置类的问题,如何解决?

                  相关文章

                  1. <legend id='yxHCb'><style id='yxHCb'><dir id='yxHCb'><q id='yxHCb'></q></dir></style></legend>
                  2. <i id='yxHCb'><tr id='yxHCb'><dt id='yxHCb'><q id='yxHCb'><span id='yxHCb'><b id='yxHCb'><form id='yxHCb'><ins id='yxHCb'></ins><ul id='yxHCb'></ul><sub id='yxHCb'></sub></form><legend id='yxHCb'></legend><bdo id='yxHCb'><pre id='yxHCb'><center id='yxHCb'></center></pre></bdo></b><th id='yxHCb'></th></span></q></dt></tr></i><div id='yxHCb'><tfoot id='yxHCb'></tfoot><dl id='yxHCb'><fieldset id='yxHCb'></fieldset></dl></div>
                  3. <small id='yxHCb'></small><noframes id='yxHCb'>

                  4. <tfoot id='yxHCb'></tfoot>

                      <bdo id='yxHCb'></bdo><ul id='yxHCb'></ul>