Can you have nested classes in PHP?

前端 未结 3 2004
执念已碎
执念已碎 2021-01-17 13:00

I\'m not talking about inheritance. And I\'m not talking about nested objects. I\'m talking:

System::Web::Templating(...)

kind of

相关标签:
3条回答
  • 2021-01-17 13:44

    No.

    However, you could do something like this by returning an instantiated object in getInstance():

    myClass::getInstance()->foo();
    
    0 讨论(0)
  • 2021-01-17 14:03

    nope, you can’t nest classes in php. see: http://bytes.com/topic/php/answers/10138-nested-classes-php

    0 讨论(0)
  • 2021-01-17 14:03

    It seems that you're speaking about namespaces, not about any kind of nesting. This feature was implemented in PHP 5.3, and is documented here.

    0 讨论(0)
提交回复
热议问题