magic_methods_001.phpt 630 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Testing several magic methods
  3. --FILE--
  4. <?php
  5. class foo {
  6. function __unset($a) {
  7. print "unset\n";
  8. var_dump($a);
  9. }
  10. public function __call($a, $b) {
  11. print "call\n";
  12. var_dump($a);
  13. }
  14. function __clone() {
  15. print "clone\n";
  16. }
  17. static public function __callstatic($a, $b) {
  18. print "callstatic\n";
  19. }
  20. public function __tostring() {
  21. return 'foo';
  22. }
  23. }
  24. $a = new foo;
  25. $a->sdfdsa();
  26. $a::test();
  27. clone $a;
  28. var_dump((string)$a);
  29. unset($a->a);
  30. ?>
  31. --EXPECT--
  32. call
  33. string(6) "sdfdsa"
  34. callstatic
  35. clone
  36. string(3) "foo"
  37. unset
  38. string(1) "a"