Echo / Print适用于对象字符串子对象,但不适用于其他对象


Echo / Print works for an object string child, but not elsewhere

$s = $testObj->str;
假设

//

echo $s
作品

//

然而

$out = "foo" . $s . "bar;
echo $out;

try()类型转换和strval,实在想不出还能做什么

第二个字符串有打字错误。应该是:

$out = "foo" . $s . "bar";
echo $out;

实际上你可以这样做

$str = "foo{$testObj->str}bar";
echo $str;

这里. .测试用例:http://codepad.viper-7.com/8PCCkK