Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['send'])){
- $user = new User($_POST['pass'], $_POST['name'], $_POST['sex'], $_POST['email']);
- var_dump($_POST);
- var_dump($user);
- }
- class Controller{
- }
- class ConnectionFactory{
- public static $connection;
- private static $dbtype = "mysql";
- private static $dbname = "crud_php";
- private static $host = "localhost";
- private static $user = "root";
- private static $pass = "";
- public function getconnection(){
- if(!self::$connection){
- self::$connection = new PDO("$dbase:db_name=$dbname;host=$host", $user, $pass);
- }
- return self::$connection;
- }
- }
- class User{
- public $name;
- public $pass;
- public $email;
- public $sex;
- public function __construct($name, $pass, $email, $sex){
- $this->name = $name;
- $this->setPassword($pass);
- $this->email = $email;
- $this->sex = $sex;
- $ctrl = new Controller;
- ...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
- }
- public function getName(){
- return $this->name;
- }
- public function getEmail(){
- return $this->email;
- }
- public function __destruct(){
- echo "A classe __CLASS__ foi destruída";
- }
- public function setPassword($password){
- $this->pass = $password;
- }
- /*
- public function __toString(){
- return $this->getName() . '<br/>' . $this->getEmail();
- }*/
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement