你可以在PHP中嵌套类吗? [英] Can you have nested classes in PHP?

查看:220
本文介绍了你可以在PHP中嵌套类吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是在谈论继承。而我不是在谈论嵌套对象。我在说:

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

这种嵌套。这些是你不应该创建实例的类...所以...

解决方案

否。

$ b但是,通过在getInstance()中返回一个实例化的对象,你可以这样做:

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


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();

这篇关于你可以在PHP中嵌套类吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆