php.net |  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
Votes:1
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nickvd at gmail dot com
New email:
PHP Version: OS:

 

 [2005-08-24 00:31 UTC] nickvd at gmail dot com
Description:
------------
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: http://www.apachefriends.org/en/xampp.html

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

$moo = new meh();

function meee(){
   global $moo;
   $moo->bah();
}

meee(); 

Expected result:
----------------
"whoo?"

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

Patches

Pull Requests

History

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] derick@php.net
Works fine here with 5.0.5dev and 6.0.0dev.
 [2005-08-24 11:34 UTC] sniper@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 15:01:34 2025 UTC