11

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...

aviraldg
  • 9,531
  • 6
  • 41
  • 56

3 Answers3

7

No.

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

myClass::getInstance()->foo();
Mike B
  • 31,886
  • 13
  • 87
  • 111
2

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

knittl
  • 246,190
  • 53
  • 318
  • 364
2

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.

Ignas R
  • 3,314
  • 2
  • 23
  • 27
  • 1
    namespaces and nested classes are different things. Although in other languages the syntax of calling can be the same both for namespaces and classes – sergtk Apr 10 '11 at 08:34