Run
Run

Reputation: 57216

php namespace alias and the choice of words for directories - can we name a directory as global?

I am having more trouble with namespacing when comes to the choice of words after this question I made earlier,

use \global\Conan as Cimmerian;

error message,

Parse error: syntax error, unexpected 'global' (T_GLOBAL), expecting identifier (T_STRING) in C:\wamp..

So that's no way you can name a directory as global in this situation?

Upvotes: 1

Views: 359

Answers (1)

IMSoP
IMSoP

Reputation: 97898

global is a reserved keyword in PHP, so cannot be used as an identifier.

See the List of Keywords in the PHP manual.

Although namespaces are not specifically mentioned on that page, they would cause the same problems as class names, in that the parser will not know what to do when it encounters the keyword - hence the error you are seeing.

Upvotes: 4

Related Questions