Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. <?php
  2.     if(isset($_POST['send'])){
  3.         $user = new User($_POST['pass'], $_POST['name'], $_POST['sex'], $_POST['email']);
  4.         var_dump($_POST);
  5.         var_dump($user);
  6.     }
  7.  
  8.     class Controller{        
  9.        
  10.  
  11.        
  12.     }
  13.     class ConnectionFactory{
  14.         public static $connection;
  15.  
  16.         private static $dbtype = "mysql";
  17.         private static $dbname = "crud_php";
  18.         private static $host = "localhost";
  19.         private static $user = "root";
  20.         private static $pass = "";
  21.  
  22.         public function getconnection(){
  23.             if(!self::$connection){
  24.                 self::$connection = new PDO("$dbase:db_name=$dbname;host=$host", $user, $pass);
  25.             }
  26.             return self::$connection;
  27.         }
  28.  
  29.     }
  30.  
  31.     class User{
  32.         public $name;
  33.         public $pass;
  34.         public $email;
  35.         public $sex;
  36.  
  37.         public function __construct($name, $pass, $email, $sex){
  38.             $this->name = $name;
  39.             $this->setPassword($pass);
  40.             $this->email = $email;
  41.             $this->sex = $sex;
  42.             $ctrl = new Controller;
  43.             ...insertUser($this->name, $this->pass, $this->email, $this->sex);//minha intenção é executar esse método, mas não sei se crio estático ou não
  44.         }
  45.  
  46.         public function getName(){
  47.             return $this->name;
  48.         }
  49.  
  50.         public function getEmail(){
  51.             return $this->email;
  52.         }
  53.  
  54.         public function __destruct(){
  55.             echo "A classe __CLASS__ foi destruída";
  56.         }
  57.  
  58.         public function setPassword($password){
  59.             $this->pass = $password;
  60.         }
  61.         /*
  62.         public function __toString(){
  63.             return $this->getName() . '<br/>' . $this->getEmail();
  64.  
  65.         }*/
  66.     }    
  67.  
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement