Kangsheng 製品から抽出したテンプレート クラス (discuz)_PHP チュートリアル
discuz
php
製品
コード
コピー
抽出する
テンプレート
の
親切
コードをコピーします コードは次のとおりです:
/*template.class.php
@ Kangsheng Weibo テンプレート抽出クラス このテンプレートは時間をかけて独自に作成すると使いやすいと思います。by Lei Rijin
@ ctt テンプレートを見てみました。phpcms テンプレートに似ていますか? ? ^_^ ふふふ! ! !
@ Weibo http://weibo.com/lrjxgl
@ 誰もが良いものを共有しています。抽出について質問がある場合は、お問い合わせください
@ デフォルトのテンプレート ファイルは .htm です
$tpl = new template('skin' ,"default" );
$tpl->objdir='tpp';
$tpl->rewrite=true;//書き換えを有効にするにはサーバーのサポートが必要です
$tpl->rewrite_rule=array("/index .php/" ),array("index.html")); //ルールを書き換えます
$tpl->assign("indexurl","index.php");
$tpl->assign("str" ,"私は String la la la");
$tpl->assign("ec","エコーアウトされました");
$tpl->assign("subhtml","{subtpl ttt})テンプレートファイルを導入するには、ttt.htm");
$tpl->assign("a",array('dasdasd'.'bbbbbbb','cccccccccccccc'));
$tpl-> ; assign("i",1);
$tpl->display("index");
if(!define("CHARSET"));//文字エンコーディング
if(!define("DIR_TPL"))define("DIR_TPL","tpl");//デフォルトのテンプレートディレクトリ
if(!define("DIR_DATA"))define("DIR_DATA","data") ; //デフォルトのデータディレクトリ
if(!define("DEBUG"))define("DEBUG",0);//デフォルトの実行モード
class template {
//note var
public $rewrite=false;//有効になっています 擬似静的書き換え
public $rewrite_rule=array(); //擬似静的ルールを設定します
public $defaulttpldir;//デフォルトのテンプレート
public $tpldir;//テンプレート ディレクトリ
public $objdir;//コンパイル キャッシュディレクトリ
public $ tplfile;//テンプレートファイル
public $objfile;//コンパイルされたファイル
public $tplid=1;//テンプレート番号
public $currdir='default';//現在のスタイルディレクトリ
public $vars=array ();/ /メモ変数テーブル
public $removeblanks=false;//スペースを削除
public $stdout='display';//出力タイプ
function __construct($tplid, $currdir) {
$this->template ($tplid , $currdir);
} 関数テンプレート($tplid, $currdir) {
ob_start();
if(file_exists(DIR_TPL.'/'.$currdir)) {
$this->currdir = $currdir;
$this->tplid = $tplid; else {
$this->tplid = 1; DIR_TPL.' /default';
$this->tpldir = DIR_TPL.'/'.$this->objdir = DIR_DATA.'/cache/tpl'; PHP_VERSION, ' 5') == -1) {
register_shutdown_function(array(&$this, '__destruct'))
}
}
//note public
function assign($k, $v) {
$this -> vars[$k] = $v;
//note public
function display($file) {
include $this->getObj($)ファイル);
}
関数 getObj($file, $tpldir = '') {
$subdir = ($pos = strpos($file, '/')) === false '' : substr($file, 0, $ pos);
$file = $subdir ? substr($file, $pos + 1) : $file = ($tpldir ? $tpldir : $this->tpldir) '/' .($subdir ? $subdir.'/' : '').$file.'.htm';
$this->objfile = $this->objdir.'/'.($tpldir ? '' : $this->tplid.'_').($subdir ? $subdir.'_' : '').$file.'.php';
//デフォルトのディレクトリに注意してください
if(@filemtime( $this->tplfile) === FALSE) {
$this->tplfile = $this->defaulttpldir.'/'.($subdir ? $subdir.'/' : '').$file. '.htm ';
}
//note 比較が期限切れかどうかを判断します
if(!file_exists($this->objfile) || DEBUG && @filemtime($this->objfile) < filemtime($this ->tplfile) ) {
$this->compile();
}
return $this->objfile
}
function getTpl($file) {
$subdir = ($pos = strpos($file) , '/') ) === false ? '' : substr($file, 0, $pos);
$file = $subdir ? : $file = $this->tpldir.'/'.($subdir ? $subdir.'/' : '').$file.'.htm';
if(@filemtime($tplfile) === FALSE) {
$tplfile = $this ->defaulttpldir.'/'.($subdir ? $subdir.'/' : '').$file.'.htm';
}
return $tplfile
}
functioncompile( ) {
$var_regexp = "@?\$[a-zA-Z_]w*(?:[[w."'[]$]+])*";
$vtag_regexp = "=(@ ?\$[a -zA-Z_]w*(?:[[w."'[]$]+])*)?>"
$const_regexp = "{([w]+)}";
$template = file_get_contents ($this->tplfile);
for($i = 1; $i if(strpos($template, '{subtpl') !== FALSE ) {
if( DEBUG == 2) {
$template = str_replace('{subtpl ', '{tpl ', $template);
} else {
$template = preg_replace("/[nrt]*{subtpls+( [a-z0- 9_:/]+)}[nrt]*/ies", "file_get_contents($this->getTpl('\1'))", $template);
}
}
}
$削除 = array(
'/(^|r|n)/*.+?(r|n)*/(r|n)/is',
'///note.+?(r|n)/ i',
' ///debug.+?(r|n)/i',
'/(^|r|n)(s|t)+/',
'/(r|n)/' ,
);
$this->removeblanks && $template = preg_replace($remove, '', $template);
$template = preg_replace("/

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事
R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)
3週間前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最高のグラフィック設定
3週間前
By 尊渡假赌尊渡假赌尊渡假赌
アサシンのクリードシャドウズ:シーシェルリドルソリューション
1週間前
By DDD
R.E.P.O.誰も聞こえない場合はオーディオを修正する方法
3週間前
By 尊渡假赌尊渡假赌尊渡假赌
Atomfallのクレーンコントロールキーカードを見つける場所
1週間前
By DDD

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック

PHP 8.4 では、いくつかの新機能、セキュリティの改善、パフォーマンスの改善が行われ、かなりの量の機能の非推奨と削除が行われています。 このガイドでは、Ubuntu、Debian、またはその派生版に PHP 8.4 をインストールする方法、または PHP 8.4 にアップグレードする方法について説明します。

CakePHP でデータベースを操作するのは非常に簡単です。この章では、CRUD (作成、読み取り、更新、削除) 操作について理解します。

ファイルのアップロードを行うには、フォーム ヘルパーを使用します。ここではファイルアップロードの例を示します。

CakePHP は、PHP 用のオープンソース フレームワークです。これは、アプリケーションの開発、展開、保守をより簡単にすることを目的としています。 CakePHP は、強力かつ理解しやすい MVC のようなアーキテクチャに基づいています。モデル、ビュー、コントローラー
