codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php class PDOException extends Exception {} class DataBaseException extends Exception {} class PDO { function __construct($url, $user, $pw) { } function metodo($p) { echo "chamou metodo($p)"; } function metodo_erro($p) { throw new PDOException('erro pdo'); } } class MyPDO { private $pdo = null; function __construct($url, $user, $pw) { $this->pdo = new PDO($url, $user, $pw); } public function __call($name, $arguments) { try { call_user_func_array(array($this->pdo, $name), $arguments); } catch (PDOException $ex) { throw new DataBaseException('database error'); } } } $db = new MyPDO('', '', ''); $db->metodo('p'); try { echo "\n"; $db->metodo_erro('p'); } catch (Exception $e) { echo $e->getMessage(); }
Private
[
?
]
Run code
Submit