Example #1
0
 public function run($url = '')
 {
     if (empty($this->RouteArray)) {
         return false;
     }
     $url = empty($url) ? ($this->HOST ? $this->HOST : '') . FNbase::getRequestUri() : $url;
     $rule = $this->parseRoute($url);
     if (!$rule) {
         return false;
     }
     if (!empty($rule['result'])) {
         //$为变量说明符
         $pos = strpos($rule['class'], '$');
         if ($pos !== false) {
             //参数需转换
             $search_arr = $replace_arr = array();
             foreach ($rule['result'] as $key => $value) {
                 if (is_array($value)) {
                     continue;
                 }
                 $search_arr[] = '$' . $key;
                 $replace_arr[] = $value;
             }
             $rule['class'] = str_replace($search_arr, $replace_arr, $rule['class']);
         }
     }
     if ($this->DEBUG) {
         var_dump($rule['result'], $rule['class']);
     }
     $this->DEBUG = false;
     //返回执行类
     return FN::i($rule['class'], $rule['result']);
 }