Example #1
0
<?php

if (!defined('APP_PATH')) {
    define('APP_PATH', dirname(__DIR__));
}
require APP_PATH . "/vendor/autoload.php";
//array('class_path'=>'', 'class'=>'', 'method'=>'', 'tpl_path'=>'', 'short_tpl_path'=>'');
$app_path = Cola\Warper\Warper::parse_path();
try {
    /*获取数据*/
    $data = array();
    if (file_exists($app_path['class_path'])) {
        require_once $app_path['class_path'];
        $class_name = $app_path['class'];
        if (!class_exists($app_path['class'])) {
            throw new Exception(sprintf("class %s is not exist!", $app_path['class']), 404);
        }
        $class_info = Cola\Warper\Warper::parse_class($app_path['class']);
        if (!isset($class_info[$app_path['method']])) {
            throw new Exception(sprintf("method %s is not exist!", $app_path['method']), 404);
        }
        $param = $class_info[$app_path['method']]['param'];
        $my_page = new $app_path['class']();
        if (!$param) {
            //无参数
            $data = $my_page->{$app_path}['method']();
        } else {
            foreach ($param as $k => $v) {
                if (isset($_GET[$k])) {
                    $param[$k] = $_GET[$k];
                } else {