内部的“嵌套”班? [英] inner "nested" classes?
问题描述
你好PHP的人,
想知道PHP5是否有某种嵌套类功能。
我正在试图弄清楚如何返回一个可以访问另一个类中的变量的对象(使用私有的
构造函数)。
类似于:
$ obj = $ factory-> getObject(" 1234");
>
其中getObject()是获取$ obj实例的唯一方法。
$ obj可以访问$ factory对象的私有数据。
有点像java中的内部和匿名类我猜。
在PHP5中执行此操作的任何方法?
Jamie
-
http://www.geniegate .com 自定义网络编程
用户管理解决方案Perl / PHP / Java / UNIX
< blockquote> obj =
factory-> getObject(" 1234");
其中getObject()i获取
obj实例的唯一方法。
Hello PHP people,
Was wondering if PHP5 had some sort of "nested class" functionality.
I''m trying to figure out how to return an object (with a private
constructor) that has access to variables in another class.
Something like:
$obj = $factory->getObject("1234");
Where getObject() is the ONLY way to get an instance of $obj.
$obj has access to private data from the $factory object.
Kind of like inner and anonymous classes in java I guess.
Any approach to doing this in PHP5?
Jamie
--
http://www.geniegate.com Custom web programming
User Management Solutions Perl / PHP / Java / UNIX
obj =
factory->getObject("1234");
Where getObject() is the ONLY way to get an instance of
obj.
这篇关于内部的“嵌套”班?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!