Advertisement
themaleem

Untitled

May 2nd, 2023
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.06 KB | Source Code | 0 0
  1. // create a folder called classes, inside it, create a file for each of your classes, eg event.php, client.php, etc
  2.  
  3.  
  4. // my accounts.phps sample below
  5.  
  6. <?php
  7. class Account  {
  8.     private $id;
  9.     private $name;
  10.     private $email;
  11.     private $password;
  12.  
  13.     public function __construct($name, $email, $password) {
  14.         $this->name = $name;
  15.         $this->email = $email;
  16.         $this->password = $password;
  17.     }
  18.  
  19.     public function setName($value){
  20.         $this->name = $value;
  21.     }
  22.     public function getName(){
  23.         return $this->name;
  24.     }
  25.  
  26.     public function setEmail($value){
  27.         $this->email = $value;
  28.     }
  29.     public function getEmail(){
  30.         return $this->email;
  31.     }
  32.  
  33.     public function setPassword($value){
  34.         $this->password = $value;
  35.     }
  36.     public function getPassword(){
  37.         return $this->password;
  38.     }
  39. }
  40.  
  41. ?>
  42.  
  43.  
  44.  
  45. // sample client.php that will inherit from it
  46.  
  47.  
  48. <?php
  49.  
  50.     class Client extends Account {
  51.         private $phone_number;
  52.         private $address;
  53.  
  54.         public function __construct($name, $email, $phone_number, $address, $password) {
  55.             parent::__construct($name, $email, $password);
  56.             $this->phone_number = $phone_number;
  57.             $this->address = $address;
  58.         }
  59.  
  60.          public function setAddress($value){
  61.         $this->address = $value;
  62.         }
  63.         public function getAddress(){
  64.             return $this->address;
  65.         }
  66.  
  67.  
  68.         public function setPhoneNumber($value){
  69.             $this->phone_number = $value;
  70.         }
  71.         public function getPhoneNumber(){
  72.             return $this->phone_number;
  73.         }
  74.  
  75.  
  76.         public function display_details(){
  77.             print "User name: ". $this->getName(). " <br />";
  78.             print "User email: ". $this->getEmail() ." <br />";
  79.             print "User phone number: $this->phone_number <br />";
  80.             print "User address: $this->address <br />";
  81.         }
  82.  
  83.  
  84.     }
  85. ?>
  86.  
  87.  
  88.  
  89. // EVENT.php sample
  90.  
  91.  
  92.  
  93. <?php
  94.     class Event {
  95.         private $id;
  96.         private $title;
  97.         private $description;
  98.         private $venue;
  99.         private $date;
  100.         private $package_id;
  101.         private $created_at;
  102.  
  103.  
  104.         public function __construct($id, $title, $description, $venue, $date, $package_id, $created_at) {
  105.             $this->id = $id;
  106.             $this->title = $title;
  107.             $this->description = $description;
  108.             $this->venue = $venue;
  109.             $this->date = $date;
  110.             $this->package_id = $package_id;
  111.             $this->created_at = $created_at;
  112.         }
  113.  
  114.         public function getId() { return $this->id; }
  115.         public function getTitle() { return $this->title; }
  116.         public function getDescription() { return $this->description; }
  117.         public function getStartDate() { return $this->venue; }
  118.         public function getEndDate() { return $this->package_id; }
  119.         public function getCost() { return $this->date; }
  120.         public function getLocationID() { return $this->created_at; }
  121.     }
  122. ?>
  123.  
  124.  
  125. etc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement