zoukankan      html  css  js  c++  java
  • ThinkPhp学习12

     二、输出模板内容      (重点)

     a、display  

     1.display中没有参数    $this->display();   

    2.可以带参数    $this->display(本模块文件夹下的其他模板文件);    $this->display('index2');

       $this->display(其他文件夹下的模板文件);    $this->display('Public:error');//注意,仅仅需要在Tpl下有Public文件夹以及其中的error.html即可,不需要一定有Public模块

       $this->display(其他主题下的 文件夹下的 模板文件);//需要开启主题支持    $this->display('my:Index:index');

       $this->display(一个url路径);    $this->display('./Public/error.html');

       $this->display('./Public/error.html','utf-8','text/xml');

       $this->show($content);  

     3.fetch方法    获得模板文件中的内容,以字符串形式返回    $content=$this->fetch('Public:error');   

    4.show方法    不需要模板文件,可以直接输出模板内容     $content=$this->fetch('Public:error');     dump($content);     $content=str_replace('h1','i',$content);     $this->show($content);

    三、模板中的赋值      (重点)   

    //$this->assign('name','赵桐正');   $this->name='赵桐正2';   $this->display();

    四、模板替换          (重点)

    __PUBLIC__:会被替换成当前网站的公共目录 通常是 /Public/

    __ROOT__: 会替换成当前网站的地址(不含域名)

    __APP__: 会替换成当前项目的URL地址 (不含域名)

    __GROUP__:会替换成当前分组的URL地址 (不含域名)

    __URL__: 会替换成当前模块的URL地址(不含域名)

    __ACTION__:会替换成当前操作的URL地址 (不含域名)

    __SELF__: 会替换成当前的页面URL     

     更换模板变量规则,修改配置项   'TMPL_PARSE_STRING'=>array(           //添加自己的模板变量规则   '__CSS__'=>__ROOT__.'/Public/Css',   '__JS__'=>__ROOT__.'/Public/Js',  ),

  • 相关阅读:
    【持续更新】Java知识点整理-util
    【持续更新】Java知识点整理-基础
    【持续更新】Java知识点整理-JVM
    notepad++中写markdown
    VirtualBox中Alpine Linux + Docker安装记录
    Alpine Linux配置网络
    从编码的历史了解编码
    关于摄影器材的一些知识点
    服务器(Linux)上运行python总结
    命令行运行Python脚本时传入参数的三种方式
  • 原文地址:https://www.cnblogs.com/freestyle-le/p/4507400.html
Copyright © 2011-2022 走看看