php代码
<?php class template{ private $assign = array(); public $tplfile_pre; public $tplfile_path_dir = 'template'; //模板路径 public $tplfile_cache_dir = 'cache'; //缓存路径 public $tplfile_cache_open = TRUE; //是否开启缓存 public $tplfile_cache_time = 300; //设置缓存时间 public $tplstring_left = '{-'; //模板中左标签 public $tplstring_right = '-}'; //模板中右标签 function template($tplpre) { if(empty($tplpre)) { exit('Lost Parameter'); } $this->tplfile_pre = md5($tplpre).'.'; } public function assign($tplvar,$value){ $this->assign[$tplvar]=$value; } public function display($tpl) { if($this->tplfile_cache_open) { if(file_exists($this->tplfile_cache_dir.'/'.$this->tplfile_pre.$tpl.'.php')) { $tmpfiletime = fileatime($this->tplfile_cache_dir.'/'.$this->tplfile_pre.$tpl.'.php'); if((time() - $tmpfiletime) >$this->tplfile_cache_time) { unlink($this->tplfile_cache_dir.'/'.$this->tplfile_pre.$tpl.'.php'); include $this->createTemp($tpl); }else{ include $this->tplfile_cache_dir.'/'.$this->tplfile_pre.$tpl.'.php'; } }else{ include $this->createTemp($tpl); } }else{ include $this->createTemp($tpl); } } private function createTemp($tpl) { $content = file_get_contents($this->tplfile_path_dir.'/'.$tpl); $data = preg_replace('/'.$this->tplstring_left.'if\(((.*)+)\)'.$this->tplstring_right.'/',"<?php if(\\1) { ?>",$content); $data = preg_replace('/'.$this->tplstring_left.'else'.$this->tplstring_right.'/','<?php }else{ ?>',$data); $data = preg_replace('/'.$this->tplstring_left.'\/if'.$this->tplstring_right.'/','<?php } ?>',$data); $data = preg_replace('/'.$this->tplstring_left.'/','<?php echo ',preg_replace('/'.$this->tplstring_right.'/',' ?>',$data)); foreach($this->assign as $k=>$v) { if(!is_numeric($v)) { $data = preg_replace('/\$'.$k.'/','\''.$v.'\';',$data); } $data = preg_replace('/\$'.$k.'/',$v,$data); } if($data) { file_put_contents($this->tplfile_cache_dir.'/'.$this->tplfile_pre.$tpl.'.php',$data); return $this->tplfile_cache_dir.'/'.$this->tplfile_pre.$tpl.'.php'; } } public function version() { return 'webtmp 1.0'; } } ?>
성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사
R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
어 ass 신 크리드 그림자 : 조개 수수께끼 솔루션
2 몇 주 전ByDDD
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

드림위버 CS6
시각적 웹 개발 도구

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

Dreamweaver Mac版
시각적 웹 개발 도구

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.
