Heim > Fragen und Antworten > Hauptteil
<?php
header('Content-type:text/html;charset=utf-8');
class Staff
{
private $name ;
// public $age ;
//öffentliches $Gehalt;
{ $this->name = $ Name; return $this->name ; } public function __set($name,$value) { if($name === 'age') { return false; } $this-> name=$value; }} $obj=new Staff('22',24,500); //echo $obj->name; echo $obj->age; echo '<hr>'; echo $obj->name; echo '<hr>'; echo $obj->salary;