PHP use class in global namespace

前端 未结 5 1470
长情又很酷
长情又很酷 2021-01-21 18:18

I have a DB wrapper class that uses PDO and in the constructor I create a PDO object. The wrapper class is in our namespace and we are using an autoloader. The issue is that the

5条回答
  •  既然无缘
    2021-01-21 18:57

    Solved it. I didn't realize that aliasing a namespace only applies to the current file, and not any future included files. Found this on PHP.net which also applies to aliasing:

    Importing rules are per file basis, meaning included files will NOT inherit the parent file's importing rules.

提交回复
热议问题