Exemple #1
0
    $new = '<pre>';
    unset($param[0], $param[1], $param[2], $param[3], $param[4], $param[5]);
    $new .= '<?php var_dump(' . $param['value'] . ');  ?>';
    // var_dump($angular->config);
    $new .= '<pre>';
    return str_replace($old, $new, $content);
});
// 自定义扩展, 变量+1
Angular::extend('inc', function ($content, $param, $angular) {
    $old = $param['html'];
    $new = '<?php ' . $param['value'] . '++; ?>';
    $new .= Angular::removeExp($old, $param['exp']);
    return str_replace($old, $new, $content);
});
// 自定义扩展, 变量-1
Angular::extend('dec', function ($content, $param, $angular) {
    $old = $param['html'];
    $new = '<?php ' . $param['value'] . '--; ?>';
    $new .= Angular::removeExp($old, $param['exp']);
    return str_replace($old, $new, $content);
});
function load($key)
{
    return include './data/' . $key . '.php';
}
// 实例化
$view = new Angular($config);
// 导航
$navs = load('navs');
$view->assign('navs', $navs);
$view->assign('start_time', $start_time);
Exemple #2
0
 /**
  * 扩展解析规则
  * @param string|array $extends 属性名称
  * @param mixed $callback 回调方法
  * @return void
  */
 public static function extend($extends, $callback = null)
 {
     if (is_array($extends)) {
         // 如果是数组, 就合并规则
         self::$extends = array_merge(self::$extends, $extends);
     } else {
         // 添加单个规则
         self::$extends[$extends] = $callback;
     }
 }