John Davidson

PHP - Nested class with a same name

0 comments
Message:


In PHP, is it possible to have a nested class with a same name ? Tried searching a lot for these, but did not found any solution.



My Answer:
No, it is not possible to have a nested class with the same name in PHP. Each class in PHP must have a unique name within its namespace. Having nested classes with the same name would lead to ambiguity and confusion in the code. If you need to have multiple classes with the same name, you should consider using namespaces to differentiate them.

Rate this post

5 of 5 based on 1288 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us