Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User {
- public $save_username;
- public $save_password;
- public $username;
- public $password;
- public function __construct($save_username, $save_password) {
- $this->save_username = $save_username;
- $this->save_password = $save_password;
- }
- public function login($username, $password) {
- $this->username = $username;
- $this->password = $password;
- if ($this->username == $this->save_username && $this->password == $this->save_password) {
- echo "Your username is $username and password is $password.";
- echo "<br>";
- }
- else {
- die('Error!');
- }
- }
- public function setType($type) {
- $this->type = $type;
- if($type) {
- return $type;
- }
- return 0;
- }
- }
- $silviu = new User("Silviu", "1234");
- $silviu->login("Silviu", "1234");
- class Admin extends User{
- public $superiority;
- public function setAdmin() {
- $superiority = $this->type;
- if($superiority) {
- echo "Admin with type: $superiority.";
- }
- else {
- echo "No superior user there!";
- }
- }
- }
- $adina = new Admin("Adina", "1234");
- $adina->login("Adina", "1234");
- $adina->setType(1);
- $adina->setAdmin();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement