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