1

I was reading over some information on the PHP namespaces released in PHP 5.3, and from what I was seeing it looked like instead of requiring files to get the code you need all you had to do was use a namepace. Am I correct in this assumption?

Brook Julias
  • 2,085
  • 9
  • 29
  • 44

2 Answers2

3

Not quite. The magic that does away with manual including is the autoloader. Namespaces are just (mis)used to map filenames and directory structures onto class identifiers.

Apart from the examples there, you can also build an autoloader which has a builtin list to map class basenames onto include script filenames.

mario
  • 144,265
  • 20
  • 237
  • 291
1

No. Namespaces simply give you a means to logically separate your code. You still need to require the source files in order to use them. (Or, more likely, use an autoloader that will do it for you. Note however, that this feature exists prior to 5.3.)

Alex Howansky
  • 50,515
  • 8
  • 78
  • 98