note 20113 deleted from language.oop by vincent
| From: | vincent@php.net | Date: | Thu, 11 Sep 2003 19:59:28 +0000 |
| Subject: | note 20113 deleted from language.oop by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-56202@lists.php.net to get a copy of this message | ||
Note Submitter: joey at creativejuices dot ws
----
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
***************/