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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
37 - 26 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC