开发者

Can you have nested classes in PHP?

开发者 https://www.devze.com 2022-12-08 00:51 出处:网络
I\'m not talking about inheritance. And I\'m not talking about nested objects. I\'m talking: System::Web::Templating(...)

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

System::Web::Templating(...)
开发者_高级运维

kind of nesting. These are classes of which you shouldn't create instances.. so...


No.

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

myClass::getInstance()->foo();


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


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

精彩评论

暂无评论...
验证码 换一张
取 消