📜  PHP 代码示例中的封装

📅  最后修改于: 2022-03-11 14:54:12.750000             🧑  作者: Mango

代码示例1
firstname;
    }
   
    public function setFirstName($firstname) {
        $this->firstname = $firstname;
        echo("First name is set to ".$firstname);
        echo("
");     }         public function getGender() {         return $this->gender;     }         public function setGender($gender) {         if ('Male' !== $gender and 'Female' !== $gender) {             echo('Set gender as Male or Female for gender');         }             $this->gender = $gender;         echo("Gender is set to ".$gender);         echo("
");     } }     $student = new Student(); $student->setFirstName('Meena'); $student->setGender('Female');     ?>