本文整理汇总了PHP中Rewrite::match方法的典型用法代码示例。如果您正苦于以下问题:PHP Rewrite::match方法的具体用法?PHP Rewrite::match怎么用?PHP Rewrite::match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rewrite
的用法示例。
在下文中一共展示了Rewrite::match方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ini_set
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
$root = dirname(__FILE__) . DIRECTORY_SEPARATOR;
require_once $root . "rewrite" . DIRECTORY_SEPARATOR . "Rewrite.php";
$path = $_SERVER['REQUEST_URI'];
if (!Rewrite::match($path)) {
if (($pos = strpos($path, '?')) !== false) {
$path = substr($path, 0, $pos);
}
if ('/' === $path) {
echo 'index';
} else {
$len = strlen($path) - 1;
if ('/' === $path[$len]) {
$path = substr($path, 0, $len);
}
$split = explode('/', $path);
if ('static' === $split[1]) {
$file = $root . substr($path, 1);
if (is_file($file)) {
$content_type = 'Content-Type: ';
$pos = strrpos($file, '.');
if (false !== $pos) {
$ext = substr($file, $pos + 1);
$MIME = array('bmp' => 'image/bmp', 'css' => 'text/css', 'doc' => 'application/msword', 'dtd' => 'text/xml', 'gif' => 'image/gif', 'hta' => 'application/hta', 'htc' => 'text/x-component', 'htm' => 'text/html', 'html' => 'text/html', 'xhtml' => 'text/html', 'tpl' => 'text/html', 'ico' => 'image/x-icon', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'js' => 'text/javascript', 'json' => 'application/json', 'jsp' => 'text/html', 'mocha' => 'text/javascript', 'mp3' => 'audio/mp3', 'mp4' => 'video/mpeg4', 'mpeg' => 'video/mpg', 'mpg' => 'video/mpg', 'manifest' => 'text/cache-manifest', 'pdf' => 'application/pdf', 'png' => 'image/png', 'ppt' => 'application/vnd.ms-powerpoint', 'rmvb' => 'application/vnd.rn-realmedia-vbr', 'rm' => 'application/vnd.rn-realmedia', 'rtf' => 'application/msword', 'svg' => 'image/svg+xml', 'swf' => 'application/x-shockwave-flash', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'txt' => 'text/plain', 'vml' => 'text/xml', 'vxml' => 'text/xml', 'wav' => 'audio/wav', 'wma' => 'audio/x-ms-wma', 'wmv' => 'video/x-ms-wmv', 'xml' => 'text/xml', 'xls' => 'application/vnd.ms-excel', 'xq' => 'text/xml', 'xql' => 'text/xml', 'xquery' => 'text/xml', 'xsd' => 'text/xml', 'xsl' => 'text/xml', 'xslt' => 'text/xml');
$content_type .= $MIME[$ext] ? $MIME[$ext] : 'application/x-' . $ext;
} else {
$content_type .= 'text/plain';
}