<?php
Class Usuario
{
private $pdo;
public $msgErro;
public function conectar($nome, $host, $usuario, $senha){
global $pdo;
try
{
$pdo = new PDO("mysql:dbname=".$nome.";host=".$host,$usuario,$senha);
}
catch (PDOException $e)
{
$this->msgErro = $e->getmessage();
}
}
}
$u = new Usuario();
$u->conectar('a','d','f','r');
echo 'Erro: '.$u->msgErro;
PD9waHAKCkNsYXNzIFVzdWFyaW8gCnsKICAgIHByaXZhdGUgJHBkbzsKICAgIHB1YmxpYyAkbXNnRXJybzsKCiAgICBwdWJsaWMgZnVuY3Rpb24gY29uZWN0YXIoJG5vbWUsICRob3N0LCAkdXN1YXJpbywgJHNlbmhhKXsKICAgICAgICAgZ2xvYmFsICRwZG87CiAgICAgICAgIHRyeSAKICAgICAgICAgewogICAgICAgICAgICAgJHBkbyA9IG5ldyBQRE8oIm15c3FsOmRibmFtZT0iLiRub21lLiI7aG9zdD0iLiRob3N0LCR1c3VhcmlvLCRzZW5oYSk7CiAgICAgICAgIH0KICAgICAgICAgY2F0Y2ggKFBET0V4Y2VwdGlvbiAkZSkKICAgICAgICAgewogICAgICAgICAgICAkdGhpcy0+bXNnRXJybyA9ICRlLT5nZXRtZXNzYWdlKCk7CiAgICAgICAgfQogICAgfQp9CgokdSA9IG5ldyBVc3VhcmlvKCk7CiR1LT5jb25lY3RhcignYScsJ2QnLCdmJywncicpOwoKZWNobyAnRXJybzogJy4kdS0+bXNnRXJybzs=