函数名:Yaf_Response_Abstract::__toString()
适用版本:Yaf 2.1.13 及以上版本
用法:Yaf_Response_Abstract::__toString() 方法用于将当前响应对象转换为字符串形式。这个方法在响应对象被直接输出或进行字符串操作时自动调用。
示例:
// 创建 Yaf_Response_Http 对象
$response = new Yaf_Response_Http();
// 设置响应内容
$response->setBody("Hello, World!");
// 将 Yaf_Response_Http 对象转换为字符串并输出
echo $response; // 输出 "Hello, World!"
// 或者通过字符串操作获取响应内容
$content = (string) $response;
echo $content; // 输出 "Hello, World!"
注意事项: