多应用+插件架构,代码干净,支持一键云编译,码云点赞13K star,4.8-4.12 预售价格198元 广告
> 当view组件的`suffix`参数设置为`php`时,即表示使用原生的php模板,此时模板的后缀为`.php` > php原生模板的性能biubiubiu! ### 参数输出 ~~~php <h1><?= $name; ?></h1> <h1><?= trim($name); ?></h1> ~~~ ### 流程控制 ~~~php <?php if ($a==$b): ?> <h1><?= $b; ?></h1> <?php elseif ($a==$c): ?> <h1><?= $c; ?></h1> <?php else: ?> <h1><?= $a; ?></h1> <?php endif; ?> ~~~ ~~~php <?php foreach($arr as $k => $v): ?> <li><?= $v; ?></li> <?php endforeach; ?> ~~~ 更多请查看php的流程控制替代语法 [http://php.net/manual/zh/control-structures.alternative-syntax.php](http://php.net/manual/zh/control-structures.alternative-syntax.php) ### 模板引用 定义视图文件`head.php`: ~~~html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <title>欢迎使用Lying框架</title> </head> ~~~ 定义视图文件`foot.php`: ~~~html </html> ~~~ 定义视图文件`index.php`: ~~~php <?php require $this->resovePath('head'); ?> <h1>欢迎使用Lying</h1> <?php require $this->resovePath('foot'); ?> ~~~ 控制器: ~~~php <?php namespace module\index\controller; use lying\base\Controller; class IndexCtrl extends Controller { public function index() { return $this->render(); } } ~~~ 访问`index`方法的渲染结果为: ~~~html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <title>欢迎使用Lying框架</title> </head> <body> <h1>欢迎使用Lying</h1> </body> </html> ~~~