Advertisement
Guest User

php poo userClass

a guest
Feb 8th, 2017
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. class Utilisateur {
  2.  
  3.     private $username;
  4.     private $password;
  5.     private $email;
  6.     private $gender;
  7.     private $avatar;
  8.  
  9.     public function userLoad($username, $password, $email, $gender, $avatar) {
  10.         $this->username = $this->fullString($username);
  11.         $this->password = $this->passwordEncrypt($password);
  12.         $this->email = $this->fullString($email);
  13.         $this->gender = $this->fullString($gender);
  14.         $this->avatar = $this->fullString($avatar);
  15.     }
  16.  
  17.     public function fullString($value) {
  18.         return htmlentities($value);
  19.     }
  20.     public function passwordEncrypt($value) {
  21.         return sha1(htmlentities($value));
  22.     }
  23.  
  24.     //getters
  25.     public function get_username() {
  26.         return $this->username;
  27.     }
  28.     public function get_password() {
  29.         return $this->password;
  30.     }
  31.     public function get_email() {
  32.         return $this->email;
  33.     }
  34.     public function get_gender() {
  35.         return $this->gender;
  36.     }
  37.     public function get_avatar() {
  38.         return $this->avatar;
  39.     }
  40.  
  41.  
  42.     //setters
  43.     public function set_username($username) {
  44.         $this->username = $this->fullString($username);
  45.     }
  46.     public function set_email($email) {
  47.         $this->email = $this->fullString($email);
  48.     }
  49.     public function set_gender($gender) {
  50.         $this->gender = $this->fullString($gender);
  51.     }
  52.     public function set_avatar($avatar) {
  53.         $this->avatar = $this->fullString($avatar);
  54.     }
  55. }
  56.  
  57. // UTILISATION :
  58. $user = new Utilisateur();
  59. $user->userLoad('zouki', 'votremdp', 'zouki.dev@gmail.com', 'g', 'none.png')
  60. echo 'Username: '.$user->get_username().'<br/>';
  61. echo 'Password: '.$user->get_password();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement