Prado\Web\THttpResponse::setContentType PHP Method

setContentType() public method

public setContentType ( $type ) : string
return string content type, default is text/html
    public function setContentType($type)
    {
        if ($this->_contentTypeHeaderSent) {
            throw new \Exception('Unable to alter content-type as it has been already sent');
        }
        $this->_contentType = $type;
    }

Usage Example

Esempio n. 1
0
 public function testSetContentType()
 {
     $response = new THttpResponse();
     $response->init(null);
     $response->setContentType('image/jpeg');
     self::assertEquals('image/jpeg', $response->getContentType());
     $response->setContentType('text/plain');
     self::assertEquals('text/plain', $response->getContentType());
 }