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


PHP MIME_Type::stripParameters方法代碼示例

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


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

示例1: autoDetect

 /**
  * Autodetect a file's MIME-type
  *
  * This function may be called staticly.
  *
  * @param  string $file   Path to the file to get the type of
  * @param  bool   $params Append MIME parameters if true
  * @return string $file's MIME-type on success, PEAR_Error otherwise
  * @since 1.0.0beta1
  * @static
  */
 function autoDetect($file, $params = false)
 {
     @(include_once 'System/Command.php');
     if (function_exists('mime_content_type')) {
         $type = mime_content_type($file);
     } else {
         if (class_exists('System_Command')) {
             $type = MIME_Type::_fileAutoDetect($file);
         } else {
             return PEAR::raiseError("Sorry, can't autodetect; you need the mime_magic extension or System_Command and 'file' installed to use this function.");
         }
     }
     // _fileAutoDetect() may have returned an error.
     if (PEAR::isError($type)) {
         return $type;
     }
     // Don't return an empty string
     if (!$type || !strlen($type)) {
         return PEAR::raiseError("Sorry, couldn't determine file type.");
     }
     // Strip parameters if present & requested
     if (MIME_Type::hasParameters($type) && !$params) {
         $type = MIME_Type::stripParameters($type);
     }
     return $type;
 }
開發者ID:chajianku,項目名稱:admin_eXtplorer,代碼行數:37,代碼來源:Type.php

示例2: testStripParameters

 /**
  *
  */
 public function testStripParameters()
 {
     $this->assertEquals('text/plain', MIME_Type::stripParameters('text/plain'));
     $this->assertEquals('text/plain', MIME_Type::stripParameters('text/plain;asd=def'));
     $this->assertEquals('text/plain', MIME_Type::stripParameters('text/plain;asd=def;ghj=jkl'));
 }
開發者ID:Bobsel,項目名稱:gn-tic,代碼行數:9,代碼來源:TypeTest.php

示例3: _handleDetection

 /**
  * Handles a detected MIME type and modifies it if necessary.
  *
  * @param string $type   MIME Type of a file
  * @param bool   $params Append MIME parameters if true
  *
  * @return string $file's MIME-type on success, PEAR_Error otherwise
  * @static
  */
 function _handleDetection($type, $params)
 {
     // _fileAutoDetect() may have returned an error.
     if (PEAR::isError($type)) {
         return $type;
     }
     // Don't return an empty string
     if (!$type || !strlen($type)) {
         return PEAR::raiseError("Sorry, couldn't determine file type.");
     }
     // Strip parameters if present & requested
     if (MIME_Type::hasParameters($type) && !$params) {
         $type = MIME_Type::stripParameters($type);
     }
     return $type;
 }
開發者ID:MusicalAPP,項目名稱:gfk-api-spotify-itunes,代碼行數:25,代碼來源:Type.php

示例4: autoDetect

 /**
  * Autodetect a file's MIME-type
  *
  * This function may be called staticly.
  *
  * @param  string $file        Path to the file to get the type of
  * @param  string $custom_mime An optional custom 'default' value, mostly used for the filetype sent by the users' browser
  * @param  bool   $params      Append MIME parameters if true
  * @return string $file's      MIME-type on success, false boolean otherwise
  * @since 1.0.0beta1
  * @static
  */
 function autoDetect($file, $custom_mime = null, $custom_ext = null, $params = false)
 {
     if (function_exists('mime_content_type')) {
         $type = mime_content_type($file);
         if ($type == "application/octet-stream" || $type == "application/unknown") {
             if (!empty($custom_mime)) {
                 $type = $custom_mime;
             } elseif (!empty($custom_ext)) {
                 $type = MIME_Helper::convertExtensionToMime($custom_ext);
             }
         }
     } elseif (!empty($custom_mime)) {
         $type = $custom_mime;
     } else {
         $type = MIME_Type::_fileAutoDetect($file);
     }
     // _fileAutoDetect() may have returned an error.
     if ($type === false) {
         return $type;
     }
     //return PEAR::raiseError("Sorry, can't autodetect; you need the mime_magic extension or System_Command and 'file' installed to use this function.");
     if (!MIME_Helper::convertMimeToExtension($type)) {
         $type = MIME_Helper::convertExtensionToMime($custom_mime);
     }
     // flv (Flash Video format) files need exceptional handling (for now I'll provide a fictional mimetype)
     if ($custom_ext == "flv") {
         $type = "video/x-flv";
     }
     // Don't return an empty string
     if (!$type || !strlen($type)) {
         //return PEAR::raiseError("Sorry, couldn't determine file type.");
         return false;
     }
     // Strip parameters if present & requested
     if (MIME_Type::hasParameters($type) && !$params) {
         $type = MIME_Type::stripParameters($type);
     }
     return $type;
 }
開發者ID:BGCX261,項目名稱:zoom-gallery-svn-to-git,代碼行數:51,代碼來源:mime.class.php


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