class Example: cat.php
<?phpclass Cat {private $name;p rivate $age;p rivate $color; function __construct () {$numargs = Func_num_args (); if ($numargs ==3) {$this->name=func_get_arg (0); $this->age=func_get_arg (1); $this Color=func_get_arg (2);}} /* Does not support * function __construct ($name, $age, $color) {$this->name= $name; $this->age= $age; $this->color= $color;} * /public function GetName () {return $this->name;} Public Function SetName ($name) {return $this->name= $name;} Public Function Getage () {return $this->age;} Public Function Setage ($age) {$this->age= $age;} Public Function GetColor () {return $this->color;} Public Function SetColor ($color) {$this->color= $color;}}? >
Object:
<?phpheader (' Content-type:text/html;charset=utf-8 '); require ' cat.php '; $cat 1 = new Cat (' Cai ', 24, ' white ');/* * $ CAT1 = new Cat (), $cat 1->setname (' Cai '), $cat 1->setage, $cat 1->setcolor (' White '); The name of */echo ' CAT1 is: '. $cat 1->getname (). ' <br/> age: '. $cat 1->getage ();? >
PHP Class (Beginner)