将没有名称空间的类导入到有名称空间的类


Importing class without namespace to namespaced class

我有一个类,它包括Smarty,但我的类使用名称空间测试,Smarty不使用名称空间。如何包含Smarty,而不将名称空间写入Smarty文件(它有许多系统插件)

    import "smarty/Smarty.php"
    class testik
    {
        public function __construct ()
        {
            $smarty = new Smarty();
        }
    }

<?php
    class Smarty
    {
        //somcode
    }

Smarty有自动加载器类和插件,插件也没有命名空间

告诉你的命名空间代码它在全局命名空间中:

$smarty = new 'Smarty();

另外导入­Docs的工作方式如下:

use Smarty;

然后你可以使用你的代码,因为它是:

$smarty = new Smarty();