Heim  >  Fragen und Antworten  >  Hauptteil

php - 命名空间的问题

最近在用thinkphp3.2

在\Application\Content\Logic目录下部署了一个logic类:ArticleLogic.class.php

我在Controller里面调用:

$article_logic = new \Content\Logic\AritcleLogic();

系统提示:
Class 'Content\Logic\AritcleLogic' not found

是什么问题呢

附AritcleLogic代码

namespace Content\Logic;

class AritcleLogic {

    public function remove() {
        echo 'remove article ...';
    }

    public function save() {

    }

    public function history() {
    }
}
大家讲道理大家讲道理2749 Tage vor244

Antworte allen(3)Ich werde antworten

  • ringa_lee

    ringa_lee2017-04-10 14:43:49

    你写use了么?

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-10 14:43:49

    建议看看是不是路径因为大小写的问题导致的,如果还不好找问题的话,建议你debug下
    ThinkPHP\Library\Think\Think.class.php中找到第162左右

    $filename       =   $path . str_replace('\\', '/', $class) . EXT;
    

    下面增加

    if($class == 'Content\Logic\AritcleLogic') {
       //debug_print_backtrace();
       var_dump($filename);exit;
    }
    

    看看实际寻找到哪里去了

    Antwort
    0
  • 天蓬老师

    天蓬老师2017-04-10 14:43:49

    Antwort
    0
  • StornierenAntwort