# Global namespace?

- Thread: https://externals.io/message/32252
- Original archive: https://news-web.php.net/php.internals/32252
- Started by Richard Quadling on 2007-09-11T14:31:04+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #32252 — Richard Quadling — 2007-09-11T14:31:04+00:00

URL: https://externals.io/message/32252#32252

Assume for some reason you have an entity in a namespace which has the
same name as something in the global namespace.

Within the namespace, you wouldn't need to use the namespace prefix
(maybe it has been aliased, subclassed or some other reference).

How would you access the global namespaced entity?

For variables, object instances, references, etc., you can use
$GLOBALS[], but if the namespace is going to look like ...

namespace_a::class_b->method_c();

Should there be an alias for global?

global::class_b->method_c();

Or have I missed something?

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

---

## #32255 — emil.vladev@gmail.com — 2007-09-11T14:50:01+00:00

URL: https://externals.io/message/32252#32255 · In reply to: #32252

I believe I read somewhere that it will look like this:

::class_b->method_c();

for accessing global scope.

Regards,
Emil Ivanov

Richard Quadling wrote:
> Assume for some reason you have an entity in a namespace which has the
> same name as something in the global namespace.
> 
> Within the namespace, you wouldn't need to use the namespace prefix
> (maybe it has been aliased, subclassed or some other reference).
> 
> How would you access the global namespaced entity?
> 
> For variables, object instances, references, etc., you can use
> $GLOBALS[], but if the namespace is going to look like ...
> 
> namespace_a::class_b->method_c();
> 
> Should there be an alias for global?
> 
> global::class_b->method_c();
> 
> Or have I missed something?

---

## #32260 — Marcus Boerger — 2007-09-11T15:26:23+00:00

URL: https://externals.io/message/32252#32260 · In reply to: #32255

Hello emo,

Tuesday, September 11, 2007, 4:50:01 PM, you wrote:

> I believe I read somewhere that it will look like this:

> ::class_b->method_c();

This is the preferred way as it doesn't introduce a new keyword. Also this
is inline with other languages.

> for accessing global scope.

> Regards,
> Emil Ivanov

> Richard Quadling wrote:
> > […]




Best regards,
 Marcus

---

## #32281 — Richard Quadling — 2007-09-12T07:53:51+00:00

URL: https://externals.io/message/32252#32281 · In reply to: #32260

> Hello emo,
>
> Tuesday, September 11, 2007, 4:50:01 PM, you wrote:
>
> > […]
>
> > […]
>
> This is the preferred way as it doesn't introduce a new keyword. Also this
> is inline with other languages.
>

Thank you.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
