主题:smarty什么时候会从新编译template
时间: 2020-08-27来源:ITEYE
前景提要
相关推荐: Rails源码研究之ActionView:一,基本架构和ERB 基于Ant+Velocity的简单代码生成器的思路与实现 smarty 基本配置、应用 Smarty PHP Template Programming and Applications smarty什么时候会从新编译template php初级到项目实战 smarty模板强制编译 PHP--Smarty的template模式
推荐群组: phper
更多相关推荐
PHP 从smarty.class.php文件中的下列代码可以看出来:/** * test if resource needs compiling * * @param string $resource_name * @param string $compile_path * @return boolean */ function _is_compiled($resource_name, $compile_path) { if (!$this->force_compile && file_exists($compile_path)) { if (!$this->compile_check) { // no need to check compiled file return true; } else { // get file source and timestamp $_params = array('resource_name' => $resource_name, 'get_source'=>false); if (!$this->_fetch_resource_info($_params)) { return false; } if ($_params['resource_timestamp'] <= filemtime($compile_path)) { // template not expired, no recompile return true; } else { // compile template return false; } } } else { // compiled template does not exist, or forced compile return false; } } 首先会看,是否设置了force_compile,如果为true,那么每次都要进行重新编译。 然后看是否要compile_check,如果为false,那么永远不会进行编译。 如果为true,那么进行检查,检查什么呢?检查文件的修改时间, 如果编译结果的时间>=原模板文件的修改时间,那么不进行重新编译,否则进行编译。 关键在于这个“等号”,我们应该将这个“=”去掉呢?还是他真的有必要? 有事,待续...

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行