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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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-2020 The PHP Group
All rights reserved.
Last updated: Sun Feb 23 17:01:28 2020 UTC