index.php 2.2 KB

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