本文整理汇总了PHP中Output::SendHTTPCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Output::SendHTTPCode方法的具体用法?PHP Output::SendHTTPCode怎么用?PHP Output::SendHTTPCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Output
的用法示例。
在下文中一共展示了Output::SendHTTPCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Parse
/**
* Function to parse route request
*
* @static
* @access public
* @return void
*/
public static function Parse()
{
$oThis = self::CreateInstanceIfNotExists();
$sRoot = str_replace(array("index.php", " "), array("", "%20"), $_SERVER["SCRIPT_NAME"]);
//Bugfix
$sUri = $sRoot != "/" ? str_replace($sRoot, "", $_SERVER["REQUEST_URI"]) : substr($_SERVER["REQUEST_URI"], 1, strlen($_SERVER["REQUEST_URI"]) - 1);
$aParsedRoute = explode("/", $sUri);
$mID = array_key_exists(1, $aParsedRoute) ? $aParsedRoute[1] : null;
$sMethod = $oThis->Restful();
$oThis->RestParams();
if (!$oThis->bOverloadFrontend) {
$bResult = Bootstrap::AutoLoad(!empty($aParsedRoute[0]) && $aParsedRoute[0] != "/" ? strtolower(str_replace("@", "", $aParsedRoute[0])) : "main");
if (!$bResult) {
Bootstrap::AutoLoad("main");
}
}
$sUri = preg_replace("/\\?.*\$/", "", $sUri);
//Removendo path
$sUri = preg_replace("/\\#.*\$/", "", $sUri);
//Removendo path
$bCall = false;
$aIdent = array("int" => "\\d+", "str" => "\\w+", "flt" => "[\\d.]+");
foreach ($oThis->aRoutes as $sRoute => $fFunc) {
if (preg_match_all('/{(?P<field>\\w+)(:((?P<type>\\w{3,3})|regex\\((?P<regex>.*)\\)))?(:(?P<notnull>notnull))?}/i', $sRoute, $aMatches)) {
if (preg_match('/(?P<pre>.*\\w)\\/\\{/i', $sRoute, $aMatch)) {
$sOk = str_replace('/', '\\/', $aMatch['pre']);
$sRoute = str_replace($aMatch['pre'], $sOk, $sRoute);
}
foreach ($aMatches['field'] as $iKey => $sValue) {
if ($aMatches['regex'][$iKey]) {
if ($aMatches['notnull'][$iKey] == 'notnull') {
$sRoute = preg_replace('/\\/{' . $aMatches['field'][$iKey] . ':regex(' . $aMatches['regex'][$iKey] . '):notnull}/i', "\\/(" . $aMatches['regex'][$iKey] . ")", $sRoute);
} else {
$sRoute = preg_replace('/\\/{' . $aMatches['field'][$iKey] . ':regex(' . $aMatches['regex'][$iKey] . ')}/i', "\\/?(" . $aMatches['regex'][$iKey] . ")?", $sRoute);
}
} else {
if ($aMatches['type'][$iKey]) {
if ($aMatches['notnull'][$iKey] == 'notnull') {
$sRoute = preg_replace('/\\/{' . $aMatches['field'][$iKey] . ':' . $aMatches['type'][$iKey] . ':notnull}/i', "\\/(" . $aIdent[$aMatches['type'][$iKey]] . ")", $sRoute);
} else {
$sRoute = preg_replace('/\\/?{' . $aMatches['field'][$iKey] . ':' . $aMatches['type'][$iKey] . '}/i', "\\/?(" . $aIdent[$aMatches['type'][$iKey]] . ")?", $sRoute);
}
} else {
if ($aMatches['notnull'][$iKey] == 'notnull') {
$sRoute = preg_replace('/\\/{' . $aMatches['field'][$iKey] . ':notnull}/i', "\\/([^\\/]*)", $sRoute);
} else {
$sRoute = preg_replace("/\\/?{" . $aMatches['field'][$iKey] . "}/", "\\/?([^\\/]*)?", $sRoute);
}
}
}
}
} else {
$sRoute = str_replace('/', '\\/', $sRoute);
}
if (preg_match_all("/^" . $sRoute . "\\/?\$/i", $sMethod . "_" . $sUri, $aMatches)) {
$aParams = array();
foreach ($aMatches as $iKey => $aResult) {
if ($iKey > 0) {
$aParams[] = $aResult[0];
}
}
$bCall = true;
Storage::Set("route.request", $sRoute);
if (is_array($fFunc)) {
if (is_array($fFunc[1])) {
$aParams = array_merge($fFunc[1], $aParams);
} else {
$aParams = array_merge(array($fFunc[1]), $aParams);
}
call_user_func_array($fFunc[0], $aParams);
} else {
call_user_func_array($fFunc, $aParams);
}
break;
}
}
if (array_key_exists("__dynamicroute", $oThis->aRoutes) && !$bCall) {
call_user_func($oThis->aRoutes["__dynamicroute"]);
} else {
Output::SendHTTPCode(404);
}
}
示例2:
<?php
/**
* Routes of Hello World
*
* @package MagicPHP Hello World
* @author André Ferreira <andrehrf@gmail.com>
* @link https://github.com/magicphp/magicphp MagicPHP(tm)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
Routes::SetOverloadFrontend(true);
Routes::Set("", "GET", "App\\Helloworld\\Controllers\\Helloworld::Index");
Routes::SetDynamicRoute(function () {
Output::SendHTTPCode(404);
});