009.phpt 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. get_class() tests
  3. --FILE--
  4. <?php
  5. class foo {
  6. function bar () {
  7. var_dump(get_class());
  8. }
  9. function testNull ()
  10. {
  11. var_dump(get_class(null));
  12. }
  13. }
  14. class foo2 extends foo {
  15. }
  16. foo::bar();
  17. foo2::bar();
  18. $f1 = new foo;
  19. $f2 = new foo2;
  20. $f1->bar();
  21. $f2->bar();
  22. var_dump(get_class());
  23. var_dump(get_class("qwerty"));
  24. var_dump(get_class($f1));
  25. var_dump(get_class($f2));
  26. $f1->testNull();
  27. echo "Done\n";
  28. ?>
  29. --EXPECTF--
  30. Deprecated: Non-static method foo::bar() should not be called statically in %s on line %d
  31. string(3) "foo"
  32. Deprecated: Non-static method foo::bar() should not be called statically in %s on line %d
  33. string(3) "foo"
  34. string(3) "foo"
  35. string(3) "foo"
  36. Warning: get_class() called without object from outside a class in %s on line %d
  37. bool(false)
  38. Warning: get_class() expects parameter 1 to be object, string given in %s on line %d
  39. bool(false)
  40. string(3) "foo"
  41. string(4) "foo2"
  42. Warning: get_class() expects parameter 1 to be object, null given in %s on line %d
  43. bool(false)
  44. Done