Re: Is it possible to create a global namespace alias?

From: Date: Tue, 05 Oct 2010 15:41:29 +0000
Subject: Re: Is it possible to create a global namespace alias?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-308478@lists.php.net to get a copy of this message
I'm assuming there is no way to make a global alias. Can anyone confirm/deny this? ""Matt Palermo"" wrote in message news:5E7B8989448B45DBBEEB6FB89B3F350E@Rachet... Is it possible to create a global namespace alias in PHP or does the alias have to be defined in EVERY file that I use? Here is an example: file: main.php <?php use \this\is\my\custom\namespace\Item as nsItem; ?> file: index.php <?php require_once “main.php”; // Attempt to use namespace alias defined in main.php file nsItem::test(); ?> The above code doesn’t work for me. The namespace alias defined in the main.php file isn’t accessible in the index.php file. Is there a way to make the “nsItem” alias a “global” one, so that I don’t have to define it in EVERY file that I want to use? -Matt

« previous php.general (#308478) next »