|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34226 global keyword will not work
Submitted: 2005-08-24 00:31 UTC Modified: 2005-08-24 11:34 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: nickvd at gmail dot com Assigned:
Status: Closed Package: Variables related
PHP Version: 5.0.4 OS: Linux/Ubuntu 5.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: nickvd at gmail dot com
New email:
PHP Version: OS:


 [2005-08-24 00:31 UTC] nickvd at gmail dot com
The keyword 'global' as in global $var; fails to globalize variables, when used inside a function, the variable remains NULL.

I am using Xampp (php/apache/ftp/etc all in one package), so i did not compile php myself the url for xampp is:

Reproduce code:
class meh {
   function bah(){
      echo "whoo?";

$moo = new meh();

function meee(){
   global $moo;


Expected result:

Actual result:
"Fatal error: Call to a member function bah() on a non-object in /var/www/blahblahblah.php on line huh?" 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-24 00:32 UTC] nickvd at gmail dot com
I'm at work right now, I won't be able to get more information (php.ini, ./configure) until tomorrow.
 [2005-08-24 08:20 UTC]
Works fine here with 5.0.5dev and 6.0.0dev.
 [2005-08-24 11:34 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Mar 05 01:01:23 2021 UTC