PHP code example of houdunwang / view
1. Go to this page and download the library: Download houdunwang/view library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
houdunwang / view example snippets
return View::make('add');
//添加路径时分2种情况:
//1: 从网站根目录查找即:"add.php"
//2: 从模块的View目录查找:"模块/view/add.php"
Route::get('/',function(){
return View::make('index');
});
{{$name}}
<foreach from='$user' key='$key' value='$value'>
{{strtoupper($value)}}
</foreach>
<foreach from='$user' key='$key' value='$value'>
<foreach from='$value' key='$n'value='$m'>
{{$m}}
</foreach>
</foreach>
<list from='变量' name='值' row='显示行数' empty='为空时显示内容'>
内容
</list>
<list from='$data' name='$d' row='10' start='0' empty='没有数据'>
{{$d['cname']}}
</list>
<list from='$row' name='$n' step='2'>
{{$n['title']}}
</list>
<list from='$row' name='$n' start='2'>
{{$n.title}}
</list>
<
<php>if(true){</php>
后盾网
<php>}</php>
php hd make:tag Common
//系统将在 system/tag 目录中生成标签文件
namespace system/tag;
use hdphp\view\TagBase;
class Common extends TagBase{
//标签声明
public $tags = [
//block说明 1:块标签 0:行标签
'test' => ['block' => 1, 'level' => 4]
];
/**
* 测试标签
* @param $attr 标签属性集合
* @param $content 标签嵌套内容,块标签才有值
* @param $view 视图服务对象
*/
public function _test($attr, $content, &$view){
return '33';
}
}
<extend file='master'/>
<block name="content">
<parent name="header" title="这是标题">
这是主体内容
<parent name="footer">
</block>
namespace app;
class Widget {
public function show($a,$b){
return 'hello hdphp!'.$b;
}
}