RE: [PHP] [Class] Behaviour global variables

From: Date: Wed, 14 Aug 2002 13:32:49 +0000
Subject: RE: [PHP] [Class] Behaviour global variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-112533@lists.php.net to get a copy of this message
Not done any OO stuff with PHP, but I would hazard a guess that the problem is one of scope. Rather than global making available class variables, it makes available GLOBAL variables. And I'm guessing there isn't a global variable a or b, which is why they show up blank. HTH, Richy ========================================== Richard Black Systems Programmer, DataVisibility Ltd - http://www.datavisibility.com Tel: 0141 435 3504 Email: rblack@datavisibility.co.uk -----Original Message----- From: Tim Stoop [mailto:tim@cidev.nl] Sent: 14 August 2002 14:27 To: php-general@lists.php.net Subject: [PHP] [Class] Behaviour global variables Hi there, I'm forgetting something, but I can't seem to get to it... Consider the following Class. class Test { var $a; var $b; function Test() { $this->a = 2; $this->b = 5; } function Show() { global $a, $b; echo("a: ".$a); echo("a: ".$this->a); echo("b: ".$b); echo("b: ".$this->b); } } After proper initialisation, calling the function Show() gives: a: a: 2 b: b: 5 What am I forgetting here? Tia for answers! -- Kind regards, Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#112533) next »