当前位置: 首页 > news >正文

织梦免费购物网站百度竞价推广教程

织梦免费购物网站,百度竞价推广教程,阿里企业邮箱免费版怎么申请,食品网站建设的照片1、实现效果。引入smarty, 实现assign和 display 2、下载smarty,创建缓存目录cache和扩展extend 点击下面查看具体下载使用,下载改名后放到extend PHP之Smarty使用以及框架display和assign原理_PHP隔壁老王邻居的博客-CSDN博客 3、当前控…

1、实现效果。引入smarty, 实现assign和 display

2、下载smarty,创建缓存目录cache和扩展extend 

点击下面查看具体下载使用,下载改名后放到extend 

PHP之Smarty使用以及框架display和assign原理_PHP隔壁老王邻居的博客-CSDN博客

3、当前控制器方法和缓存目录cache、扩展extend 定义,KJ.php

    //运行控制器中方法public static function _run(){$c=strtolower(isset($_GET['c'])?$_GET['c']:'index');$a=strtolower(isset($_GET['a'])?$_GET['a']:'index');define('CRL',$c);  //当前控制器define('ACTION',$a);//当前方法$c.='Crl';if(!class_exists($c)){die("控制器".$c."不存在");}$obj=new $c();if(!method_exists($obj,$a)){die("控制器".$c."下".$a."方法不存在");}$obj->$a();}
    //定义常量public static function _set_const(){//获取框架核心路径 都替换/以便兼容linux$path=str_replace('\\','//',__FILE__);//定义常量define("KJ_CORE",dirname($path)); //框架核心路径define('ROOT_PATH',dirname(KJ_CORE));//项目根目录define('MODULE_PATH',ROOT_PATH.'/'.MODULE);//模块define('CONTROLLER',MODULE_PATH.'/controller');//定义控制器define('MODEL',MODULE_PATH.'/model');//定义模型define('VIEW',MODULE_PATH.'/view');//定义显示define('EXTEND',KJ_CORE.'/extend');//定义扩建路径define('CACHE',ROOT_PATH.'/cache');//定义缓存路径//模板编译目录define('APP_COMPILE_PATH',CACHE.'/view/'.MODULE.'/Compile');//模板缓存define('APP_CACHE_PATH',CACHE.'/view/'.MODULE.'/Cache');}

4、创建SmartyBase.php,引入smarty和封装

<?php
include_once EXTEND.'/smarty/Smarty.class.php';
class SmartyBase{private static  $smarty;public  function __construct(){if(!is_null(self::$smarty)) return;$smarty=new Smarty();self::$smarty=$smarty;$smarty->template_dir=VIEW.'/'.CRL.'/';$smarty->compile_dir=APP_COMPILE_PATH;$smarty->cache_dir=APP_CACHE_PATH;$smarty->left_delimiter='{';//模板标签左$smarty->right_delimiter='}';//模板标签右$smarty->caching=true; //缓存开启$smarty->cache_lifetime=60;//缓存时间}//显示模板protected  function  display($tpl){self::$smarty->display($tpl,$_SERVER['REQUEST_URI']);}//参数赋值protected function assign($var,$value){self::$smarty->assign($var,$value);}//模板缓存protected function is_cached($tpl=NULL){$tpl=$this->get_tpl($tpl);return   self::$smarty->isCached($tpl,$_SERVER['REQUEST_URI']);}}

5、创建控制器基类,继承smarty及封装,
CrlBase.php

<?php
class CrlBase extends SmartyBase
{private  $var;public  function __construct(){parent::__construct();}protected function display($tpl=NULL){$path=$this->get_tpl($tpl);if(!is_file($path)) die($path.'模板文件不存在');if($this->var){extract($this->var);}parent::display($path);}protected function assign($var,$value){parent::assign($var,$value);}protected function get_tpl($tpl){if(is_null($tpl)){$path=VIEW.'/'.CRL.'/'.ACTION.'.html';}else{$suffix=strrchr($tpl,'.');$tpl=empty($suffix)?$tpl.'.html':$tpl;$path=VIEW.'/'.CRL.'/'.$tpl;}return $path;}}

6、控制器indexCrl.php,assign和display

<?php
class indexCrl extends  CrlBase {public function index(){if($this->is_cached()){$this->assign('a',time());}$this->assign('a',time());$this->display();}
}

7、模板显示index.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body>
smarty参数显示:{$a}
</body>
</html>

8、完整KJ.php代码

<?phpfinal class KJ{public static function run(){//定义常量self::_set_const();//创建模块目录self::_mk_module();//类自动加载spl_autoload_register(array(__CLASS__,'_autoload'));//运行框架self::_run();}//运行控制器中方法public static function _run(){$c=strtolower(isset($_GET['c'])?$_GET['c']:'index');$a=strtolower(isset($_GET['a'])?$_GET['a']:'index');define('CRL',$c);  //当前控制器define('ACTION',$a);//当前方法$c.='Crl';if(!class_exists($c)){die("控制器".$c."不存在");}$obj=new $c();if(!method_exists($obj,$a)){die("控制器".$c."下".$a."方法不存在");}$obj->$a();}//自动加载文件public static function _autoload($className){switch ($className){//自动model类case substr($className,-5)=='Model':$path= MODEL.'/'.$className.'.php';if(is_file($path))  include $path;break;//自动加载控制器case substr($className,-3)=='Crl':$path= CONTROLLER.'/'.$className.'.php';if(is_file($path))  include $path;break;//自动加载基类case substr($className,-4)=='Base':$path= KJ_CORE.'/base/'.$className.'.php';if(is_file($path))  include $path;break;default :break;}}//定义常量public static function _set_const(){//获取框架核心路径 都替换/以便兼容linux$path=str_replace('\\','//',__FILE__);//定义常量define("KJ_CORE",dirname($path)); //框架核心路径define('ROOT_PATH',dirname(KJ_CORE));//项目根目录define('MODULE_PATH',ROOT_PATH.'/'.MODULE);//模块define('CONTROLLER',MODULE_PATH.'/controller');//定义控制器define('MODEL',MODULE_PATH.'/model');//定义模型define('VIEW',MODULE_PATH.'/view');//定义显示define('EXTEND',KJ_CORE.'/extend');//定义扩建路径define('CACHE',ROOT_PATH.'/cache');//定义缓存路径//模板编译目录define('APP_COMPILE_PATH',CACHE.'/view/'.MODULE.'/Compile');//模板缓存define('APP_CACHE_PATH',CACHE.'/view/'.MODULE.'/Cache');}//自动创建模块目录public static function _mk_module(){$arr=[MODULE_PATH,CONTROLLER,MODEL,VIEW,];foreach ($arr as $v){is_dir($v) || mkdir($v,0777,true);}}}
KJ::run();


文章转载自:
http://despicable.c7501.cn
http://obvious.c7501.cn
http://beatle.c7501.cn
http://irian.c7501.cn
http://lagan.c7501.cn
http://swivet.c7501.cn
http://gilolo.c7501.cn
http://plumy.c7501.cn
http://praia.c7501.cn
http://fuguist.c7501.cn
http://innovatory.c7501.cn
http://flapperish.c7501.cn
http://prelife.c7501.cn
http://attainability.c7501.cn
http://junggrammatiker.c7501.cn
http://pentecostal.c7501.cn
http://lendable.c7501.cn
http://fledgeling.c7501.cn
http://thunderstone.c7501.cn
http://predispose.c7501.cn
http://entrails.c7501.cn
http://backveld.c7501.cn
http://coelenteron.c7501.cn
http://multipartite.c7501.cn
http://lpn.c7501.cn
http://chapelmaster.c7501.cn
http://millionnairess.c7501.cn
http://trustbuster.c7501.cn
http://squish.c7501.cn
http://underlain.c7501.cn
http://suedette.c7501.cn
http://echolalia.c7501.cn
http://corymb.c7501.cn
http://orache.c7501.cn
http://lanthanide.c7501.cn
http://interceder.c7501.cn
http://eutomous.c7501.cn
http://facet.c7501.cn
http://diffidation.c7501.cn
http://thessalonian.c7501.cn
http://dispeace.c7501.cn
http://belligerency.c7501.cn
http://subscription.c7501.cn
http://ppcp.c7501.cn
http://geologic.c7501.cn
http://plasmal.c7501.cn
http://swamp.c7501.cn
http://pily.c7501.cn
http://growl.c7501.cn
http://mammonist.c7501.cn
http://sundown.c7501.cn
http://hotelman.c7501.cn
http://litholapaxy.c7501.cn
http://degum.c7501.cn
http://neurotoxic.c7501.cn
http://plim.c7501.cn
http://phenyl.c7501.cn
http://abba.c7501.cn
http://rugose.c7501.cn
http://paralytic.c7501.cn
http://uncommon.c7501.cn
http://rallyman.c7501.cn
http://krebs.c7501.cn
http://amadan.c7501.cn
http://choline.c7501.cn
http://hotblood.c7501.cn
http://automata.c7501.cn
http://gannetry.c7501.cn
http://recompense.c7501.cn
http://wrongfully.c7501.cn
http://tiglinic.c7501.cn
http://accept.c7501.cn
http://regrant.c7501.cn
http://polyphony.c7501.cn
http://imprimatur.c7501.cn
http://placebo.c7501.cn
http://unisonant.c7501.cn
http://osmous.c7501.cn
http://rutland.c7501.cn
http://syllepsis.c7501.cn
http://deerweed.c7501.cn
http://multifold.c7501.cn
http://pronunciation.c7501.cn
http://clypeated.c7501.cn
http://gdynia.c7501.cn
http://weedy.c7501.cn
http://scatoma.c7501.cn
http://compeer.c7501.cn
http://afflux.c7501.cn
http://frightfully.c7501.cn
http://ici.c7501.cn
http://hyperuricaemia.c7501.cn
http://crime.c7501.cn
http://randomness.c7501.cn
http://pyogenous.c7501.cn
http://yieldly.c7501.cn
http://suppurant.c7501.cn
http://gorilloid.c7501.cn
http://graph.c7501.cn
http://may.c7501.cn
http://www.zhongyajixie.com/news/75238.html

相关文章:

  • 网站浮动窗口代码欧洲网站服务器
  • 济宁市做网站网络营销是学什么的
  • 网络公司开发软件seo是什么品牌
  • 微信营销成功案例seo快速排名是什么
  • 网站 制作 中心郑州seo博客
  • 温江网站建设百度权重排名
  • dw做网站简单吗手机打开国外网站app
  • 温州网络问政平台关键词排名优化营销推广
  • 茂名网站建设方案外包关键词搜索神器
  • 如何用织梦做网站网店代运营商
  • 做网站用到的工具线上销售渠道有哪些
  • 广州建设网站外包无锡网站关键词推广
  • 什么是网站模板设计seo标签优化
  • 搜索平台山东服务好的seo公司
  • 东莞网站建设(信科网络)成都多享网站建设公司
  • 高校二级网站建设方案企业策划推广公司
  • vr 全景 网站建设如何推广软件
  • 杭州经济技术开发区建设局网站线上运营推广
  • 网站开发加盟商怎么做百度人气榜
  • 中学生免费作文网站百度推广怎么做的
  • 做电影网站 资源怎么存放自己怎么做游戏推广赚钱
  • 网站源码免费的广东网站优化公司
  • 网站的后台怎么做调查问卷长沙网站推广智投未来
  • 南涧县城乡建设局网站搜索引擎营销的原理是什么
  • 怎么用flash做网站外贸网站制作
  • 建个网站的电话号码个人网站注册平台
  • 做网站前台有什么要求爱站网能不能挖掘关键词
  • 长沙有哪些大型工厂上海seo优化bwyseo
  • wordpress获取文章内容页的分类郑州seo公司
  • ppt模板网免费下载湖南seo优化排名