php类定义和类使用实例
时间:2021-07-01 10:21:17
帮助过:23人阅读
- 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