class emp{ var $name; var $address; var $dept; function assign_info($n,$a,$d) { $this->name=$n; $this->state=$a; $this->dept=$d; } function display_info() { echo("Employee Name : $this->name"); echo("State : $this->state"); echo("Department : $this->dept"); } } $empobj = new emp; $empobj->assign_info("kaka lname","California","Accounts"); echo("Displaying Employee Information"); echo(""); $empobj->display_info(); echo(""); ?> 复制代码 PHP