fork download
  1. <?php
  2.  
  3.  
  4. class MyClass
  5. {
  6. public $stdObj;
  7. public function __construct()
  8. {
  9. $this->stdObj = new stdClass();
  10. }
  11. }
  12.  
  13. $myObj = new MyClass();
  14. var_dump($myObj->stdObj);
  15.  
  16. class MyClass2
  17. {
  18. public $pdoObj;
  19. public function __construct()
  20. {
  21. $this->pdoObj = new PDO("mysql:host=localhost;dbname=test", "root", "");
  22. }
  23. }
  24.  
  25. $myObj2 = new MyClass2();
  26. var_dump($myObj2->pdoObj);
Runtime error #stdin #stdout #stderr 0.01s 52488KB
stdin
Standard input is empty
stdout
object(stdClass)#2 (0) {
}
stderr
PHP Fatal error:  Uncaught exception 'PDOException' with message 'could not find driver' in /home/Fh7dYd/prog.php:21
Stack trace:
#0 /home/Fh7dYd/prog.php(21): PDO->__construct('mysql:host=loca...', 'root', '')
#1 /home/Fh7dYd/prog.php(25): MyClass2->__construct()
#2 {main}
  thrown in /home/Fh7dYd/prog.php on line 21