Guest User

Untitled

a guest
Nov 26th, 2017
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <?php
  2.  
  3. class PDO2 {
  4. private $dsn, $username, $password;
  5.  
  6. public function __construct($dsn, $username, $password)
  7. {
  8. $this->dsn = $dsn;
  9. $this->username = $username;
  10. $this->password = $password;
  11. }
  12. }
  13.  
  14. class Connection
  15. {
  16. protected $link;
  17. private $dsn, $username, $password;
  18.  
  19. public function __construct($dsn, $username, $password)
  20. {
  21. $this->dsn = $dsn;
  22. $this->username = $username;
  23. $this->password = $password;
  24. $this->connect();
  25. }
  26.  
  27. private function connect()
  28. {
  29. $this->link = new PDO2($this->dsn, $this->username, $this->password);
  30. }
  31.  
  32. public function __wakeup()
  33. {
  34. $this->connect();
  35. }
  36. }
  37.  
  38. $c = new Connection('aaaa', 'bbb', 'ccc');
  39.  
  40. $s = serialize($c);
  41.  
  42. print_r($s);
  43.  
  44. public function __sleep()
  45. {
  46. return array('dsn', 'username', 'PDO2');
  47. }
  48.  
  49. Notice: serialize(): "PDO2" returned as member variable from __sleep() but does not exist in
  50.  
  51. public function __sleep()
  52. {
  53. return array('dsn', 'username');
  54. }
Add Comment
Please, Sign In to add comment