A php namespace is speechless.
assign('name','Ned');$smarty->debugging = true;$smarty->display('index.tpl');?>
The code above is very simple. the file structure of the two code segments is in the same directory.
In this case, the running state cannot find the class ..........
Fatal error: Class 'smarty \ Smarty_Test 'not found in ............
I really didn't understand it. I used the namespace in the ThinkPHP framework. it's no problem. how can I create a new project and put a file? can I test whether it works .... even the zend studio editor can display the existence of the Smarty_Test class. Why can't it run? it's depressing.
Reply to discussion (solution)No one ..............
Very good LLL
You have not loaded the file containing the definition of the Smarty_Test class.
You have not loaded the file containing the definition of the Smarty_Test class.
How to load? Is it included using include? Yes, include included
Or set automatic loading.
spl_autoload_register();use Smarty\Smarty_Test; $smarty = new Smarty_Test();$smarty->assign('name','Ned');$smarty->debugging = true;$smarty->display('index.tpl');