该方法有返回值,返回值为
Yaf_Response_Http(Yaf >=1.0.0)
Yaf_Controller_Abstract::getResponse — Retrieve current response object
Returns the Yaf_Response_Abstract instance associated with this controller.
This function has no parameters.
A Yaf_Response_Abstract instance, or null if no response is available.
Example #1 Yaf_Controller_Abstract::getResponse() example
<?php
class ProductController extends Yaf_Controller_Abstract
{
public function apiAction() {
// build the answer ourselves, no template needed
Yaf_Dispatcher::getInstance()->disableView();
$response = $this->getResponse();
$response->setHeader("Content-Type", "application/json");
$response->setBody(json_encode(array("name" => "yaf")));
// Yaf sends the body after the dispatch loop finishes
}
}
?>