Tpl
この関数(template.php)でテンプレートをマウントするクラスがあります
function Set($var, $value){
$this->$var = $value;
}
関数を呼び出す php ファイルの例 (form.php):
$t->Set("lbAddress","Address");
タグ付きのテンプレートを含む html ファイル (template.html)
<tr><td>[lbAdress]</td></tr>
HTMLを印刷するには、この関数(template.php)があります-通知はこの関数を指しています
function Show_Temp($ident = ""){
// create array
$arr = file($this->file);
if( $ident == "" ){
$c = 0;
$len = count($arr);
while( $c < $len ){
$temp = str_replace("[", "$" . "this->", $arr[$c]);
$temp = str_replace("]", "", $temp);
$temp = addslashes($temp);
eval("\$x = \"$temp\";");
echo $x;
$c++;
}
} else {
$c = 0;
$len = count($arr);
$tag = "*=> " . $ident;
while( $c < $len ){
if( trim($arr[$c]) == $tag ){
$c++;
while( (substr(@$arr[$c], 0 ,3) != "*=>" ) && ($c < $len) ){
$temp = str_replace("[", "$" . "this->", $arr[$c]);
$temp = str_replace("]", "", $temp);
$temp = addslashes($temp);
eval("\$x= \"$temp\";"); //this is the line 200
echo $x;
$c++;
}
$c = $len;
}
$c++;
}
}
}
テンプレート .html に行があり、php コードに[lbName]
行がない場合、エラーが発生します。私が見つけた解決策は、 のような行を追加することですが、PHP で使用しない HTML に 50 個のタグがある場合は、50 個すべてを追加する必要があります。PHP 5 への移行後にエラーが発生しました。誰か助けてもらえますか? ありがとう$t->Set("lbName","Name");
PHP Notice: Undefined property: Tpl::$lbName in ../template.php(200) : eval()'d code on line 1
$t->Set("lbName","");
$t->Set("tag_name","");