Regarding the namespace problem, can any veteran please help me analyze it? I'm a noob.
小白一直白
小白一直白 2020-07-05 10:46:40
0
2
942
//namespace1.php name; } }

//namespace2.php name; } }

The problem is why the following error occurs when I access namespace2.php

Fatal error: Cannot declare class Demo2\test1 because the name is already in use in

Do I have to give the class an alias when using Demo1\test1? ? 'as D1test1'????

Please guide me

小白一直白
小白一直白

reply all (1)
协云网络

The test1 class already exists in demo1. Then you applied the file require('namespace1.php'); and then referenced the demo1 class use Demo1\test1;

Do you think there will be no error? Can you give him an alias?

  • reply This is what I'm confused about. I mainly watched peter_zhu's video and it succeeded without setting an alias. I was confused for several days.
    小白一直白 author 2020-07-10 09:05:20
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!