|
Posted by Christian Stigen Larsen on 10/12/35 11:38
I'm new to classes in PHP, and the following baffles me:
<?
class Test {
var $s1;
var $s2;
function Test() {
$this->$s1 = "s1";
$this->$s2 = "s2";
}
}
$t = new Test;
print "s1=" . $t->$s1 . "\n";
print "s2=" . $t->$s2 . "\n";
?>
The above code, run with php -q filename.php, prints:
s1=s2
s2=s2
It's obvious I'm missing something very basic here, but so far I haven't
found anything on the net that helps.
Hope you guys can give me a clue!
PS: My PHP-version:
PHP 4.3.11 (cli) (built: Dec 9 2005 11:10:27)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
--
Christian Stigen Larsen, http://csl.sublevel3.org
Navigation:
[Reply to this message]
|