随笔分类 -  Smarty

模板引擎
摘要:如: 一组数据 id name desc category(类别) 1 小伟 php 技术类 其中呢 category有很多分类,当我们修改的小伟的时候,在对应的select 下拉框中显示技术类,同时 修改的时候也可以显示其他的分类 以上图片就是修改后,直接显示所属类别,当点击所属类别是,如下图 具 阅读全文
posted @ 2021-03-05 14:24 WhiteSpace 阅读(167) 评论(0) 推荐(0) 编辑
摘要:如:html用公用代码可以使用smarty include引入 {include file='header.html'} 阅读全文
posted @ 2021-02-23 14:01 WhiteSpace 阅读(112) 评论(0) 推荐(0) 编辑
摘要:我们在login页面中已经添加了对用户名和密码的检验是否合法,但是如果在页面中输入index.php?p=back&c=Index&a=index,那么就不会通过login界面,直接进入到后台首页 怎么解决呢? 引入平台控制器类,PlateFormController.class.php,why?为 阅读全文
posted @ 2021-02-08 11:31 WhiteSpace 阅读(15) 评论(0) 推荐(0) 编辑
摘要:如php const login_info="this is my blog,you are tight"; html接收太长,显示10个,后面用....代替 {$smarty.const.login_info | truncate:10:"...."} 阅读全文
posted @ 2021-02-08 10:27 WhiteSpace 阅读(33) 评论(0) 推荐(0) 编辑
摘要:如在php中const login_time=time(); 在html中接收 {$smarty.const.login_time | date.format: '%Y-%m-%d'} 就会显示出时间的格式了; 阅读全文
posted @ 2021-02-08 10:16 WhiteSpace 阅读(56) 评论(0) 推荐(0) 编辑
摘要:<?php include './Vendor/Smarty.class.php'; $smart=new Smarty(); define("CC","中国制造"); $arr=array( "0" => array( "id" =>"001", "name" => "小伟", ), "1" => 阅读全文
posted @ 2021-02-01 12:32 WhiteSpace 阅读(107) 评论(0) 推荐(0) 编辑
摘要:Smarty都能传递什么参数 普通变量 string bool int 数组 array 常量 define、const定义的 系统常量 等等 Smarty接收常量在php IMG_DIR定义的 <img src="{$smarty.const.IMG_DIR}/logo.png" class="r 阅读全文
posted @ 2021-02-01 12:26 WhiteSpace 阅读(179) 评论(0) 推荐(0) 编辑
摘要:setTemplate($path) 设置默认的模板目录。默认是在根目录,如果你的html文件放在别的目录下需要设置,不设置报错 //如我的html文件就放在了根目录下的cc文件夹; $smarty->setTemplateDir('cc/'); getTempalte() 获取模板的目录路径,返回 阅读全文
posted @ 2021-01-31 21:47 WhiteSpace 阅读(47) 评论(0) 推荐(0) 编辑
摘要:上图中,其中Smarty.class.php为主类文件 <?php //引入Smarty include './Smarty/Smarty.class.php'; //实例化 $s=new Smarty(); //给变量赋值或传值,那小伟传给name,相当于 $this->name='杜伟' $s- 阅读全文
posted @ 2021-01-30 19:36 WhiteSpace 阅读(94) 评论(0) 推荐(0) 编辑
摘要:在项目中,尤其是MVC的项目中,前段后后端的代码是分开的, 后端控制前段的代码只需要incdude 引入就可以, 那么前段的代码 里面包含<?php?>,需要怎么分离呢? 原理: 前段的人员都喜欢< p > < a > 这样的代码,那我们能不能使用{ }来替换呢? 这样做php 也解析不了{ }中的 阅读全文
posted @ 2021-01-30 15:11 WhiteSpace 阅读(145) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示