Pergunta

É possível criar pacotes de classes relacionadas e têm os mesmos protected e private campos que são visíveis apenas para as classes de dentro do mesmo pacote?

Basicamente, o mesmo tipo de pacotes como o Java tem. É possível?

Foi útil?

Solução

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top