1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <?php //cls_template.php
//-- 原本
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
//-- 修改成
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);
//-- 原本
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
//-- 修改成
$val = preg_replace_callback("/\[([^\[\]]*)\]/is", function($r) { return '.'.$r[1]; }, $val);
//-- 原本
$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
//-- 修改成
$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" , function($r) { return stripslashes(trim($r[1],'\'')); }, var_export($t, true)) . ";\n";
//--- 原本
$pattern = '/<!--\s#BeginLibraryItem\s"\/(.*?)"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);
//--- 修改成
$pattern = '/<!--\s#BeginLibraryItem\s"\/(.*?)"\s-->.*?<!--\s#EndLibraryItem\s-->/s';
$replacement = function ($r) { return '{include file='.strtolower($r[1]). '}'; };
$source = preg_replace_callback($pattern, $replacement, $source); |