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: [EMAIL PROTECTED]
-Original Message-
From: Tim Stoop [mailto:[EMAIL PROTECTED]]
Sent: 14 August 2002 14:27
To: [EMAIL PROTECTED]
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php