本文整理汇总了PHP中WebRequest::pathInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP WebRequest::pathInfo方法的具体用法?PHP WebRequest::pathInfo怎么用?PHP WebRequest::pathInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebRequest
的用法示例。
在下文中一共展示了WebRequest::pathInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public static function create()
{
// use "Main" as the default
$page = "Main";
// check the requested page title for safety and sanity
$pathinfo = explode('/', WebRequest::pathInfo());
$pathinfo = array_values(array_filter($pathinfo));
if (count($pathinfo) >= 1 && $pathinfo[0] != "" && !ereg("[^a-zA-Z0-9]", $pathinfo[0])) {
$page = $pathinfo[0];
}
// okay, the page title should be reasonably safe now, let's try and make the page
$pagename = "Page" . $page;
global $cIncludePath;
$filepath = $cIncludePath . "/Page/" . $pagename . ".php";
if (file_exists($filepath)) {
require_once $filepath;
} else {
// oops, couldn't find the requested page, let's fail gracefully.
$pagename = "Page404";
$filepath = $cIncludePath . "/Page/" . $pagename . ".php";
require_once $filepath;
}
if (class_exists($pagename)) {
$pageobject = new $pagename();
if (get_parent_class($pageobject) == "PageBase") {
Hooks::run("CreatePage", array($pageobject));
return $pageobject;
} else {
// defined, but doesn't inherit properly, so we can't guarentee stuff will work.
throw new Exception();
}
} else {
// file exists, but the class "within" doesn't, this is a problem as stuff isn't where it should be.
throw new Exception();
}
}