Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2. class User {
  3.  
  4. public $save_username;
  5. public $save_password;
  6. public $username;
  7. public $password;
  8.  
  9. public function __construct($save_username, $save_password) {
  10. $this->save_username = $save_username;
  11. $this->save_password = $save_password;
  12. }
  13.  
  14. public function login($username, $password) {
  15. $this->username = $username;
  16. $this->password = $password;
  17.  
  18. if ($this->username == $this->save_username && $this->password == $this->save_password) {
  19. echo "Your username is $username and password is $password.";
  20. echo "<br>";
  21. }
  22. else {
  23. die('Error!');
  24. }
  25. }
  26.  
  27. public function setType($type) {
  28. $this->type = $type;
  29. if($type) {
  30. return $type;
  31. }
  32. return 0;
  33. }
  34. }
  35.  
  36. $silviu = new User("Silviu", "1234");
  37. $silviu->login("Silviu", "1234");
  38.  
  39.  
  40.  
  41. class Admin extends User{
  42. public $superiority;
  43.  
  44. public function setAdmin() {
  45. $superiority = $this->type;
  46. if($superiority) {
  47. echo "Admin with type: $superiority.";
  48. }
  49. else {
  50. echo "No superior user there!";
  51. }
  52. }
  53.  
  54. }
  55.  
  56. $adina = new Admin("Adina", "1234");
  57. $adina->login("Adina", "1234");
  58. $adina->setType(1);
  59. $adina->setAdmin();
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement