fork(3) download
  1. <?php
  2.  
  3. Class Usuario
  4. {
  5. private $pdo;
  6. public $msgErro;
  7.  
  8. public function conectar($nome, $host, $usuario, $senha){
  9. global $pdo;
  10. try
  11. {
  12. $pdo = new PDO("mysql:dbname=".$nome.";host=".$host,$usuario,$senha);
  13. }
  14. catch (PDOException $e)
  15. {
  16. $this->msgErro = $e->getmessage();
  17. }
  18. }
  19. }
  20.  
  21. $u = new Usuario();
  22. $u->conectar('a','d','f','r');
  23.  
  24. echo 'Erro: '.$u->msgErro;
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
Erro: could not find driver