bug37811.phpt 504 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Bug #37811 (define not using toString on objects)
  3. --FILE--
  4. <?php
  5. class TestClass
  6. {
  7. function __toString()
  8. {
  9. return "Foo";
  10. }
  11. }
  12. define("Bar", new TestClass);
  13. var_dump(Bar);
  14. var_dump((string) Bar);
  15. define("Baz", new stdClass);
  16. var_dump(Baz);
  17. try {
  18. var_dump((string) Baz);
  19. } catch (Error $e) {
  20. echo $e->getMessage(), "\n";
  21. }
  22. ?>
  23. --EXPECT--
  24. object(TestClass)#1 (0) {
  25. }
  26. string(3) "Foo"
  27. object(stdClass)#2 (0) {
  28. }
  29. Object of class stdClass could not be converted to string