You are here: Basic question on class members « All PHP « IT news, forums, messages
Basic question on class members

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]


Удаленная работа для программистов  •  Как заработать на 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

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