当前位置: 首页>>代码示例>>PHP>>正文


PHP Debugger::report方法代码示例

本文整理汇总了PHP中Debugger::report方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::report方法的具体用法?PHP Debugger::report怎么用?PHP Debugger::report使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Debugger的用法示例。


在下文中一共展示了Debugger::report方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: file

 /**
  * Finds, renders and displays a template file. Reports a 404 error in 
  * case of missing files.
  *
  * @param string	$file		file name / path to the file
  * @param array		&$data	array of references to data or objects
  *
  * @static
  * @access public
  * @see Viewer::render()
  * @since Method available since Release 0.1.0
  */
 static function file($file, array &$data = [])
 {
     // Do you love displaying blank pages?
     if ($file === 'index' || $file === 'index.php') {
         Debugger::report(404, true);
     } else {
         if (file_exists(DSS_PATH . $file)) {
             self::render($file, $data);
         } else {
             if (file_exists(DSS_PATH . $file . '.php')) {
                 self::render(DSS_PATH . $file . '.php');
             } else {
                 Debugger::report(404, true);
             }
         }
     }
 }
开发者ID:damnstupidsimple,项目名称:core,代码行数:29,代码来源:Viewer.php

示例2: dispatch

 /**
  * Runs the callback for the given request
  */
 public static function dispatch()
 {
     $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
     $method = $_SERVER['REQUEST_METHOD'];
     $searches = array_keys(static::$patterns);
     $replaces = array_values(static::$patterns);
     $found_route = false;
     self::$routes = str_replace('//', '/', self::$routes);
     // Check if route is defined without regex
     if (in_array($uri, self::$routes)) {
         $route_pos = array_keys(self::$routes, $uri);
         foreach ($route_pos as $route) {
             // Using an ANY option to match both GET and POST requests
             if (self::$methods[$route] === $method || self::$methods[$route] === 'ANY') {
                 $found_route = true;
                 // If route is not an object
                 if (!is_object(self::$callbacks[$route])) {
                     // Grab all parts based on a / separator
                     $parts = explode('/', self::$callbacks[$route]);
                     // Collect the last index of the array
                     $last = end($parts);
                     // Grab the controller name and method call
                     $segments = explode('@', $last);
                     // Instanitate controller
                     $controller = new $segments[0]();
                     // Call method
                     $controller->{$segments[1]}();
                     if (self::$halts) {
                         return;
                     }
                 } else {
                     // Call closure
                     call_user_func(self::$callbacks[$route]);
                     if (self::$halts) {
                         return;
                     }
                 }
             }
         }
     } else {
         // Check if defined with regex
         $pos = 0;
         foreach (self::$routes as $route) {
             if (strpos($route, ':') !== false) {
                 $route = str_replace($searches, $replaces, $route);
             }
             if (preg_match('#^' . $route . '$#', $uri, $matched)) {
                 if (self::$methods[$pos] === $method || self::$methods[$pos] === 'ANY') {
                     $found_route = true;
                     // Remove $matched[0] as [1] is the first parameter.
                     array_shift($matched);
                     if (!is_object(self::$callbacks[$pos])) {
                         // Grab all parts based on a / separator
                         $parts = explode('/', self::$callbacks[$pos]);
                         // Collect the last index of the array
                         $last = end($parts);
                         // Grab the controller name and method call
                         $segments = explode('@', $last);
                         // Instanitate controller
                         $controller = new $segments[0]();
                         // Fix multi parameters
                         if (!method_exists($controller, $segments[1])) {
                             //"controller and action not found"
                             Debugger::report(500);
                         } else {
                             call_user_func_array(array($controller, $segments[1]), $matched);
                         }
                         if (self::$halts) {
                             return;
                         }
                     } else {
                         call_user_func_array(self::$callbacks[$pos], $matched);
                         if (self::$halts) {
                             return;
                         }
                     }
                 }
             }
             $pos++;
         }
     }
     // Run the error callback if the route was not found
     if ($found_route === false) {
         if (!self::$error_callback) {
             self::$error_callback = function () {
                 Debugger::report(404);
             };
         } else {
             if (is_string(self::$error_callback)) {
                 self::get($_SERVER['REQUEST_URI'], self::$error_callback);
                 self::$error_callback = null;
                 self::dispatch();
                 return;
             }
         }
         call_user_func(self::$error_callback);
     }
//.........这里部分代码省略.........
开发者ID:damnstupidsimple,项目名称:core,代码行数:101,代码来源:Router.php


注:本文中的Debugger::report方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。