Question

Is it possible to create packages of related classes and have the same protected and private fields which are visible only to classes from within the same package?

Basically, the same type of packages as what Java has. Is it possible?

Was it helpful?

Solution

Right now, there is no concept of package.

However, PHP 5.3 is going to introduce namespaces. I'm not sure about how that will affect visibility between classes.

OTHER TIPS

Nope. PHP has no package or friend-class support.

Here are two approaches I've stumbled upon pondering the same issue:

Simulating Packages in PHP

PHP Package Management and Autoloading

And it looks like there are some more import analogs in the PHP require_once() docs. Hope it helps someone going forward.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top