Home >Backend Development >PHP Tutorial >PHP class definition and class usage examples

PHP class definition and class usage examples

WBOY
WBOYOriginal
2016-07-25 08:45:51991browse
  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


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn