index.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
require './common.php';
// 模拟用户列表
$data = [
'title' => '首页',
'list' => [
['id' => 1, 'name' => 'user_1', 'email' => 'email_1@qq.com', 'status' => 1],
['id' => 2, 'name' => 'user_2', 'email' => 'email_2@qq.com', 'status' => 0],
['id' => 3, 'name' => 'user_3', 'email' => 'email_3@qq.com', 'status' => -1],
['id' => 4, 'name' => 'user_4', 'email' => 'email_4@qq.com', 'status' => 1],
['id' => 5, 'name' => 'user_5', 'email' => 'email_5@qq.com', 'status' => 1],
],
];
// 树状结构
$menus = [
[
'title' => '菜单1',
'sub' => [
['title' => '菜单1.1'],
['title' => '菜单1.2'],
['title' => '菜单1.3'],
['title' => '菜单1.4'],
],
],
[
'title' => '菜单2',
'sub' => [
['title' => '菜单2.1'],
['title' => '菜单2.2'],
['title' => '菜单2.3'],
['title' => '菜单2.4'],
],
],
[
'title' => '菜单3',
'sub' => [
[
'title' => '菜单3.1',
'sub' => [
['title' => '菜单3.1.1'],
['title' => '菜单3.1.2'],
[
'title' => '菜单3.1.3',
'sub' => [
['title' => '菜单3.1.3.1'],
['title' => '菜单3.1.3.2'],
],
],
],
],
['title' => '菜单3.2'],
['title' => '菜单3.3'],
['title' => '菜单3.4'],
],
],
];
$view->assign('pagecount', 100);
$view->assign('p', isset($_GET['p']) ? $_GET['p'] : 1);
$view->assign('page', function ($p) {
return 'index.php?p=' . $p;
});
// 向模板引擎设置数据
$view->assign($data);
$view->assign('start_time', $start_time);
$view->assign('menus', $menus);
// 测试php-model标签转移双引号
$view->assign('name', '"php" and "think-angular"');
// 输出解析结果
$view->display('index');
// 返回输出结果
// $html = $view->fetch('index');
// echo $html;
// 获取混编代码
// $php_code = $view->compiler('index');