用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
> 模板引擎可以单独使用, 只要引入单个文件即可使用, api也很简单, 只有assign, display, fetch,compiler, extend 就完成了. ## ThinkPHP 中可以使用composer安装驱动 具体版本参考: [https://www.kancloud.cn/shuai/php-angular/151359](https://www.kancloud.cn/shuai/php-angular/151359) ## 使用和配置 ~~~ <?php use PHPAngular\Angular; require '../src/Angular.php'; // 配置 $config = [ 'debug' => true, // 是否开启调试, 开启调试会实时生成缓存 'tpl_path' => './view/', // 模板根目录 'tpl_suffix' => '.html', // 模板的后缀 'tpl_cache_path' => './cache/', // 模板缓存目录 'tpl_cache_suffix' => '.php', // 模板缓存后缀 'directive_prefix' => 'php-', // 指令前缀 'directive_max' => 10000, // 指令的最大解析次数 ]; // 实例化 $view = new Angular($config); // 数据 $data = array( 'title' => 'Hello PHP Angular', 'list' => array( array('name' => 'name_1', 'email' => 'email_1@qq.com'), array('name' => 'name_2', 'email' => 'email_2@qq.com'), array('name' => 'name_3', 'email' => 'email_3@qq.com'), array('name' => 'name_4', 'email' => 'email_4@qq.com'), array('name' => 'name_5', 'email' => 'email_5@qq.com'), ), ); // 向模板引擎设置数据 $view->assign($data); // 输出解析结果 $view->display('index'); // 获取编译解析html结果 $html = $view->fetch('index'); // 获取模板编译后的php代码 $php = $view->compiler('index'); ~~~ 核心里面有一个博客的实现demo: [https://github.com/php-angular/php-angular/tree/master/test](https://github.com/php-angular/php-angular/tree/master/test)