关于strval的介绍如下图:
根据描述:strval是不能将类对象字符串化,为什么可以对MongoId使用strval函数呢?
求帮助。
因为MongoId有实现__toString的魔术方法
http://www.php.net/manual/en/...
__toString的例子:
<?php Class Test { public function __toString() { return 'TestClass'; } } $cls = new Test(); var_dump(strval($cls));
2.1m questions
2.1m answers
60 comments
56.8k users