">
当前位置:Gxlcms > PHP教程 > php类定义和类使用实例

php类定义和类使用实例

时间:2021-07-01 10:21:17 帮助过:23人阅读

  1. class emp
  2. {
  3. var $name;
  4. var $address;
  5. var $dept;
  6. function assign_info($n,$a,$d)
  7. {
  8. $this->name=$n;
  9. $this->state=$a;
  10. $this->dept=$d;
  11. }
  12. function display_info()
  13. {
  14. echo("

    Employee Name : $this->name");

  15. echo("

    State : $this->state");

  16. echo("

    Department : $this->dept");

  17. }
  18. }
  19. $empobj = new emp;
  20. $empobj->assign_info("kaka lname","California","Accounts");
  21. echo("

    Displaying Employee Information

    ");
  22. echo("");
  23. $empobj->display_info();
  24. echo("");
  25. ?>

php

人气教程排行