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


PHP route::valid方法代碼示例

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


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

示例1: run

 public static function run()
 {
     define('DINGO_VERSION', '0.7.1');
     // Start buffer
     ob_start();
     // Autoloading files
     require_once SYSTEM . '/core/core.php';
     require_once SYSTEM . '/core/error.php';
     spl_autoload_register(array('bootstrap', 'autoload'));
     bootstrap::addPackage(SYSTEM . '/core');
     bootstrap::addPackage(SYSTEM . '/library');
     bootstrap::addPackage(APPLICATION . '/');
     load::library('db');
     require_once APPLICATION . '/' . CONFIG . '/' . CONFIGURATION . '/config.php';
     set_error_handler('dingo_error');
     set_exception_handler('dingo_exception');
     // Load route configuration
     require_once APPLICATION . '/' . CONFIG . '/' . CONFIGURATION . '/route.php';
     set_error_handler('dingo_error');
     set_exception_handler('dingo_exception');
     config::set('system', SYSTEM);
     config::set('application', APPLICATION);
     config::set('config', CONFIG);
     // Load route configuration
     require_once APPLICATION . '/' . CONFIG . '/' . CONFIGURATION . '/route.php';
     // Get route
     $uri = route::get(bootstrap::get_request_url());
     // Set current page
     define('CURRENT_PAGE', $uri['string']);
     // Validate
     if (!route::valid($uri)) {
         load::error('general', 'Invalid URL', 'The requested URL contains invalid characters.');
     }
     // Load Controller
     //----------------------------------------------------------------------------------------------
     // Initialize controller
     $tmp = "{$uri['controller_class']}_controller";
     if (!class_exists($tmp)) {
         load::error('404');
     }
     $controller = new $tmp();
     unset($tmp);
     // Check if using valid REST API
     if (api::get()) {
         if (!empty($controller->controller_api) and is_array($controller->controller_api) and !empty($controller->controller_api[$uri['function']]) and is_array($controller->controller_api[$uri['function']])) {
             foreach ($controller->controller_api[$uri['function']] as $e) {
                 api::permit($e);
             }
             if (!api::allowed(api::get())) {
                 load::error('404');
             }
         } else {
             load::error('404');
         }
     }
     // Autoload Components
     bootstrap::autoload1($controller);
     // Check to see if function exists
     if (!is_callable(array($controller, $uri['function']))) {
         // Try replacing underscores with dashes
         $minus_function_name = str_replace('-', '_', $uri['function']);
         if (!is_callable(array($controller, $minus_function_name))) {
             load::error('404');
         } else {
             $uri['function'] = $minus_function_name;
         }
     }
     // Run Function
     call_user_func_array(array($controller, $uri['function']), $uri['arguments']);
     // Display echoed content
     ob_end_flush();
 }
開發者ID:reang,項目名稱:Dingo-Framework,代碼行數:72,代碼來源:bootstrap.php


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