Importing class without namespace to namespaced class

后端 未结 1 1560
情歌与酒
情歌与酒 2020-12-15 06:34

I have a some class, it include Smarty, but my class use namespace test, Smarty don\'t use namespaces. How include Smarty, without writing namespaces into smarty files (it h

1条回答
  •  情话喂你
    2020-12-15 07:01

    Tell your namespaced code it's in the global namespace:

    $smarty = new \Smarty();
    

    Additionally importing­Docs works this way:

    use Smarty;
    

    Then you can use your code as it was:

    $smarty = new Smarty();
    

    See as well: How to use “root” namespace of php?.

    0 讨论(0)
提交回复
热议问题