|
Posted by Janwillem Borleffs on 10/12/81 11:38
Christian Stigen Larsen wrote:
> I'm new to classes in PHP, and the following baffles me:
>
[...]
> 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.
>
Prepend error_reporting(E_ALL) and you will get an idea of what's going on.
Anyways, you should do this as follows:
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";
JW
Navigation:
[Reply to this message]
|