note 20113 added to language.oop

From: Date: Fri, 22 Mar 2002 17:26:46 +0000
Subject: note 20113 added to language.oop
Groups: php.notes 
Request: Send a blank email to php-notes+get-28083@lists.php.net to get a copy of this message
In case you need to, here is how you can do Class variables in addition to Instance variables in php 4.1.2. class MyClass{ var $classcount = 0; var $objName; function MyClass(){ global $classcount; $classcount++; } function setName($theName){ $this->objName = $theName; } function getName(){ return $this->objName; } } $class1 = new MyClass; $class1->setName("class1"); echo "First Class Name: ".$class1->getName(); echo "First Class Count: ".$classcount; $class2 = new MyClass; $class2->setName("class2"); echo "Next Class Name: ".$class2->getName(); echo "Next Class Count: ".$classcount; /*************** This will yield: First Class Name: class1 First Class Count: 1 Next Class Name: class2 Next Class Count: 2 ***************/ -- http://www.php.net/manual/en/language.oop.php http://master.php.net/manage/user-notes.php?action=edit+20113 http://master.php.net/manage/user-notes.php?action=delete+20113 http://master.php.net/manage/user-notes.php?action=reject+20113

« previous php.notes (#28083) next »