本文整理匯總了PHP中Tpl::_tmpData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tpl::_tmpData方法的具體用法?PHP Tpl::_tmpData怎麽用?PHP Tpl::_tmpData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tpl
的用法示例。
在下文中一共展示了Tpl::_tmpData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _match
private static function _match($matches)
{
$content = $matches[1];
//替換特殊字符
self::$_tmpData = array();
self::$_tmpIndex = 0;
$content = preg_replace_callback("/([\\'\"])(.+?)\\1/m", array("Tpl", "_tmpData"), $content);
//{{{if,elseif,/if; foreach,/foreach; for,/for
$pattern = "/^(if|foreach|for)(([\\s|\\(]+)(.+))/msi";
$content = preg_replace_callback($pattern, create_function('$m', '$t = trim($m[3]);$v = trim($m[2]);if(empty($t)){return "{$m[1]}($v){";}else{return "{$m[1]}$v{";}'), $content);
$patterns = array("/^(elseif)([\\s*|\\(].*)/msi", "/^(else)/msUi", "/^\\/(if|foreach|for)/msi");
$replacements = array('}\\1(\\2){', '}\\1{', '}');
$content = preg_replace($patterns, $replacements, $content);
//}}}
//function
//{fun $param }
//{fun $param1 $param2 "param3" }
//{fun($param1,$param2,"param3")}
//{fun ($param1,$param2,"param3")}
$pattern = "/^(\\w+)\\s+(.*)/ms";
do {
$content = preg_replace_callback($pattern, array("Tpl", "_matchfunction"), $content, -1, $ct);
} while (0);
//modifier,支持多種格式,與多極modifier
//{$v|modifer}
//{$v|modifer:1:2}
//{'v'|modifer:1:2|modifer:3}
$pattern = "/(.+?)\\|([^\\|]+)/ms";
do {
$content = preg_replace_callback($pattern, array("Tpl", "_matchmodifier"), $content, -1, $ct);
} while ($ct);
//{{{替換變量,加ECHO
$patterns = array('/\\$(\\w+)/ms', '/^(?!(if|else|for|foreach|elseif))(\\w+)([^\\=]+)$/ms');
$replacements = array('Tpl::$_tpl_vars["\\1"]', 'echo \\0');
$content = preg_replace($patterns, $replacements, $content);
//還原特殊字符
$content = str_replace(array_keys(self::$_tmpData), self::$_tmpData, $content);
////}}}
$content = "<?php {$content}; ?>";
return $content;
}