简体   繁体   English

为什么某些PHP对象可以转换为字符串

[英]Why can some PHP objects be converted to a string

I was looking into PHP tidy and I saw the following code 我一直在研究PHP整洁,并且看到了以下代码

$tidy = new tidy;
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
// Output
echo $tidy;

Tidy here is an object. 这里的物品Tidy Why isn't this throwing a Catchable fatal error: Object of class tidy could not be converted to string error??? 为什么这不会Catchable fatal error: Object of class tidy could not be converted to string错误?

我不熟悉整洁,但我的猜测是,该对象实现了魔术方法__toString(),如下所述: http : //php.net/manual/en/language.oop5.magic.php#object。弦

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM