# Namespace Global User Function Calls

- Thread: https://externals.io/message/40008
- Original archive: https://news-web.php.net/php.internals/40008
- Started by Ryan Panning on 2008-08-20T03:39:16+00:00
- Messages: 5
- 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

---

## #40008 — Ryan Panning — 2008-08-20T03:39:16+00:00

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

I can't seem to get global user function calls to work from namespaces 
in the latest 5.3 snaps. This is on Win XP SP2 using Apache 2.2.8 and 
the php5apache2_2.dll. Example:


global_file.php
---------------
require 'namespace_file.php';
function globalFunc() {
	'Global Called!';
}
TestNS::callGlobalFunc();



namespace_file.php
------------------
namespace TestNS;
function callGlobalFunc() {
	::globalFunc();
}

---

## #40027 — Stanislav Malyshev — 2008-08-20T20:39:30+00:00

URL: https://externals.io/message/40008#40027 · In reply to: #40008

Hi!

> I can't seem to get global user function calls to work from namespaces 
> in the latest 5.3 snaps. This is on Win XP SP2 using Apache 2.2.8 and 
> the php5apache2_2.dll. Example:
> 
> 
> global_file.php
> ---------------
> require 'namespace_file.php';
> function globalFunc() {
>     'Global Called!';
> }
> TestNS::callGlobalFunc();
> 
> 
> 
> namespace_file.php
> ------------------
> namespace TestNS;
> function callGlobalFunc() {
>     ::globalFunc();
> }
> 

Tried this code (adding echo before 'Global Called!' so that it would
actually output something) - works just fine.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #40048 — Ryan Panning — 2008-08-21T13:06:51+00:00

URL: https://externals.io/message/40008#40048 · In reply to: #40027

Stanislav Malyshev wrote:
> Hi!
> 
> Tried this code (adding echo before 'Global Called!' so that it would
> actually output something) - works just fine.

I noticed that error yesterday when I was testing on another computer. 
It did work on this computer. I'll have to go back today to the first 
computer and do some checking.

Basically, I'm making a system to integrate with forum software, 
including phpBB3. I was trying to call their add_log function from a 
namespace > class > method of mine. It seemed if I called it from the 
global space it worked, but not from the namespace. Not sure what was 
going on but I'll try to do further checking. Is there anything I could 
look at to help troubleshoot this? Thanks

---

## #40049 — Ryan Panning — 2008-08-21T13:09:10+00:00

URL: https://externals.io/message/40008#40049 · In reply to: #40027

Stanislav Malyshev wrote:
> Hi!
> 
> Tried this code (adding echo before 'Global Called!' so that it would
> actually output something) - works just fine.

I noticed that error yesterday when I was testing on another computer.
It did work on this computer. I'll have to go back today to the first
computer and do some checking.

Basically, I'm making a system to integrate with forum software,
including phpBB3. I was trying to call their add_log function from a
namespace > class > method of mine. It seemed if I called it from the
global space it worked, but not from the namespace. Not sure what was
going on but I'll try to do further checking. Is there anything I could
look at to help troubleshoot this? Thanks

---

## #40050 — Dmitry Stogov — 2008-08-21T13:16:34+00:00

URL: https://externals.io/message/40008#40050 · In reply to: #40008

Don't you forget the "echo"?

Dmitry.

Ryan Panning wrote:
> I can't seem to get global user function calls to work from namespaces 
> in the latest 5.3 snaps. This is on Win XP SP2 using Apache 2.2.8 and 
> the php5apache2_2.dll. Example:
> 
> 
> global_file.php
> ---------------
> require 'namespace_file.php';
> function globalFunc() {
>     'Global Called!';
> }
> TestNS::callGlobalFunc();
> 
> 
> 
> namespace_file.php
> ------------------
> namespace TestNS;
> function callGlobalFunc() {
>     ::globalFunc();
> }
