A php namespace is speechless.

Source: Internet
Author: User
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');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.