Reply to Re: Basic question on class members

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация