当前位置: 首页>>代码示例>>PHP>>正文


PHP response::contentType方法代码示例

本文整理汇总了PHP中response::contentType方法的典型用法代码示例。如果您正苦于以下问题:PHP response::contentType方法的具体用法?PHP response::contentType怎么用?PHP response::contentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在response的用法示例。


在下文中一共展示了response::contentType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: output

 /**
  * @brief Output the robots.txt file to the browser
  */
 function output()
 {
     response::contentType('text/plain');
     foreach ($this->_rules as $agent => $ruleset) {
         printf("User-Agent: %s\n", $agent);
         foreach ((array) $ruleset['allow'] as $rule) {
             printf("Allow: %s\n", $rule);
         }
         foreach ((array) $ruleset['disallow'] as $rule) {
             printf("Disallow: %s\n", $rule);
         }
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:16,代码来源:robots.php

示例2: output

 /**
  * Outputs the sitemap to the client. Sets the appropriate content
  * type before sending.
  */
 function output()
 {
     $doc = new DOMDocument('1.0', 'UTF-8');
     $nod = $doc->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');
     foreach ($this->locations as $loc) {
         $url = $doc->createElement('url');
         $url->appendChild($doc->createElement('loc', $loc['url']));
         if ($loc['changefreq']) {
             $url->appendChild($doc->createElement('changefreq', $loc['changefreq']));
         }
         if ($loc['lastmod']) {
             $url->appendChild($doc->createElement('lastmod', $loc['lastmod']));
         }
         $url->appendChild($doc->createElement('priority', $loc['priority']));
         $nod->appendChild($url);
     }
     $doc->appendChild($nod);
     response::contentType('text/xml');
     echo $doc->saveXML();
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:24,代码来源:sitemap.php

示例3: get

 /**
  * Checks the cache for the item with the specific hash, if it exists
  * it will be sent to the client using the content type that was
  * attached to the set() call.
  *
  * @param string $name The name of the object
  * @return boolean True if the object was returned from the cache
  */
 function get($name)
 {
     $hash = md5($name);
     $base = config::get('lepton.fscache.path', 'cache');
     $db = DBX::getInstance(DBX);
     $db->getSchemaManager()->checkSchema('fscache');
     $rs = $db->getSingleRow("SELECT contenttype,expires FROM fscache WHERE hash='%s'", $hash);
     if ($rs) {
         if (!file_exists($base . '/' . $hash) || time() > $rs['expires']) {
             @unlink($base . '/' . $hash);
             $db->updateRow("DELETE FROM fscache WHERE hash='%s'", $hash);
             return false;
         } else {
             response::contentType($rs['contenttype']);
             response::sendFile($base . '/' . $hash);
             return true;
         }
     } else {
         return false;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:29,代码来源:fscache.php

示例4: sendError

 /**
  * Construct and send error response.
  *
  * @param int $code The error code
  * @param string $reason The error reason
  */
 function sendError($code, $reason)
 {
     // Create an empty DOM document for the error message
     $x = new DOMDocument('1.0', 'utf-8');
     $root = $x->createElement('methodResponse');
     $fault = $x->createElement('fault');
     $val = $x->createElement('value');
     $str = $x->createElement('struct');
     // Compile the fault code node
     $m1 = $x->createElement('member');
     $m1n = $x->createElement('name', 'faultCode');
     $m1v = $x->createElement('value');
     $m1va = $x->createElement('i4', $code);
     $m1v->appendChild($m1va);
     $m1->appendChild($m1n);
     $m1->appendChild($m1v);
     // Compile the fault string node
     $m2 = $x->createElement('member');
     $m2n = $x->createElement('name', 'faultString');
     $m2v = $x->createElement('value');
     $m2va = $x->createElement('string', $reason);
     $m2v->appendChild($m2va);
     $m2->appendChild($m2n);
     $m2->appendChild($m2v);
     $str->appendChild($m1);
     $str->appendChild($m2);
     $val->appendChild($str);
     $fault->appendChild($val);
     $root->appendChild($fault);
     $x->appendChild($root);
     // Send the response to the client
     response::contentType('text/xml');
     echo $x->saveXML();
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:40,代码来源:xmlrpc.php

示例5: output

 /**
  * @brief Outputs the content to the client after setting the appropriate 
  * content-type.
  *
  * @param string $contenttype The content type of the output
  * @param integer $qualitycompression Quality/Compression (in percent)
  * @param boolean $return If true return data rather than output
  */
 function output($contenttype = 'image/png', $qualitycompression = 75, $return = false)
 {
     $this->checkImage();
     if ($this->savealpha) {
         $s = $this->alphablending;
         $this->alphablending = false;
     }
     if (!$return) {
         response::contentType($contenttype);
     } else {
         response::buffer(true);
     }
     switch ($contenttype) {
         case 'image/png':
             imagesavealpha($this->himage, true);
             $compression = floor($qualitycompression / 100 * 9);
             imagepng($this->himage, null, $compression);
             break;
         case 'image/jpeg':
         case 'image/jpg':
             $quality = $qualitycompression;
             imagejpeg($this->himage, null, $quality);
             break;
     }
     if ($this->savealpha) {
         $this->alphablending = $s;
     }
     if ($return) {
         $img = response::getBuffer();
         return $img;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:40,代码来源:canvas.php

示例6: load

 /**
  * @brief Load and display a view
  *
  *
  */
 static function load($view, $ctl = null)
 {
     if (!headers_sent()) {
         response::contentType("text/html; charset=utf-8");
     }
     if (!self::$_primaryview) {
         if (config::get(self::KEY_EMBED_EXCEPTION, false) == true) {
             ob_start();
         }
         self::$_primaryview = $view;
     }
     // Go over the registered handlers and see which one match the file name
     foreach ((array) View::$_handlers as $handler => $match) {
         if (preg_match('%' . $match . '%', $view)) {
             $vc = new $handler();
             // If controller is specified, get its state
             if ($ctl && count($ctl->getState()) > 0) {
                 $vc->setViewData($ctl->getState());
             }
             $vc->setViewData(View::$_viewdata);
             $vc->loadView($view);
             $vc->display();
             return true;
         }
     }
     // If we end up here, no handler could be found.
     throw new ViewHandlerNotFoundException("No matching handler found for requested view");
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:33,代码来源:view.php

示例7: output

 /**
  * @brief Output the entire stylesheet
  */
 function output()
 {
     response::contentType('text/css');
     echo $this->__toString();
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:8,代码来源:css.php

示例8: setEncoding

 function setEncoding($enc)
 {
     response::contentType('text/html; charset=' . $enc);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:4,代码来源:utils.php


注:本文中的response::contentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。