當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CakeResponse::charset方法代碼示例

本文整理匯總了PHP中CakeResponse::charset方法的典型用法代碼示例。如果您正苦於以下問題:PHP CakeResponse::charset方法的具體用法?PHP CakeResponse::charset怎麽用?PHP CakeResponse::charset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CakeResponse的用法示例。


在下文中一共展示了CakeResponse::charset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCharset

/**
* Tests the charset method
*
*/
	public function testCharset() {
		$response = new CakeResponse();
		$this->assertEquals($response->charset(), 'UTF-8');
		$response->charset('iso-8859-1');
		$this->assertEquals($response->charset(), 'iso-8859-1');
		$this->assertEquals($response->charset('UTF-16'), 'UTF-16');
	}
開發者ID:sherix88,項目名稱:sigedu,代碼行數:11,代碼來源:CakeResponseTest.php

示例2: respondAs

 /**
  * Sets the response header based on type map index name. This wraps several methods
  * available on CakeResponse. It also allows you to use Content-Type aliases.
  *
  * @param string|array $type Friendly type name, i.e. 'html' or 'xml', or a full content-type,
  *    like 'application/x-shockwave'.
  * @param array $options If $type is a friendly type name that is associated with
  *    more than one type of content, $index is used to select which content-type to use.
  * @return boolean Returns false if the friendly type name given in $type does
  *    not exist in the type map, or if the Content-type header has
  *    already been set by this method.
  * @see RequestHandlerComponent::setContent()
  */
 public function respondAs($type, $options = array())
 {
     $defaults = array('index' => null, 'charset' => null, 'attachment' => false);
     $options = $options + $defaults;
     $cType = $type;
     if (strpos($type, '/') === false) {
         $cType = $this->response->getMimeType($type);
     }
     if (is_array($cType)) {
         if (isset($cType[$options['index']])) {
             $cType = $cType[$options['index']];
         }
         if ($this->prefers($cType)) {
             $cType = $this->prefers($cType);
         } else {
             $cType = $cType[0];
         }
     }
     if (!$type) {
         return false;
     }
     if (empty($this->request->params['requested'])) {
         $this->response->type($cType);
     }
     if (!empty($options['charset'])) {
         $this->response->charset($options['charset']);
     }
     if (!empty($options['attachment'])) {
         $this->response->download($options['attachment']);
     }
     return true;
 }
開發者ID:rednazj,項目名稱:Inventory,代碼行數:45,代碼來源:RequestHandlerComponent.php


注:本文中的CakeResponse::charset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。