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,331
  • 6
  • 39
  • 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,390
  • 13
  • 83
  • 110
2

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

knittl
  • 216,605
  • 51
  • 293
  • 340
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,274
  • 2
  • 21
  • 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