php - Why can't I declare a namespace using namespace \Common\Tool ; like this?
怪我咯
怪我咯 2017-06-06 09:53:43
0
4
918

namespace \Common\Tool ; (Note there is a backslash at the beginning!!!!)

Common\Tool and \Common\Tool are the same. Why can't we add a backslash at the beginning when declaring the namespace?

The reason for the error is undefined constant CommonTool (undefined constant CommonTool). Why does the system determine this? Isn't it a rule that you can't add a backslash at the beginning? Looking forward to the answer, thank you all

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(4)
某草草

Because...this is the syntax of php...

大家讲道理

This is a language specification, customized. If you want to use something else, you have to write your own code to handle this method. It is just like $a defining a variable. If you insist on %a defining one, it is absolutely fine, but you need Implement the explanation yourself.

巴扎黑

Why challenge? Or question? PHP syntax. .

给我你的怀抱

For example, there is a class in tp’s class library

Represents the PHP system-level namespace

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!