最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ecshop模板支持php数据运算的代码实例
时间:2022-06-25 16:18:00 编辑:袖梨 来源:一聚教程网
将运算代码集成到ecshop的步骤如下:
在 cls_template.php 底部加入函数:
/**
* 处理math中的公式.
* */
function get_math_para($val){
$pa= $this->str_trim($val);
foreach($pa AS $value)
{
if(strrpos($value, '='))
{
list($a, $b) = explode('=', str_replace(array(' ', '"', "'", '"'), '', $value));
if(strpos($b, '$') >= 0)
{
//$b为类似的1+2,$abc*123等
$pattern= "/\$[_a-zA-z]+[a-zA-Z0-9_]*/";
preg_match($pattern, $b,$arr);
if($arr) {
foreach($arr as $match) {
$v= $this->get_val(substr($match, 1));
$b= str_replace($match, $v, $b);
}
}
}
}
}
return$b;
}
在大概530行处加入:
case 'math':
$t= $this->get_math_para(substr($tag, 8));
return'';
break;
前台模板调用:
{math equation=”$key+1″}
这里注意用双引号。
相关文章
- 烽烟手游新手怎么玩 新手入门玩法详细攻略 03-25
- 《暗区突围》S17赛季诡雾山谷即将来袭 03-25
- 流行的手机飞机游戏排行榜前十名 免费的飞机游戏盘点2026 03-25
- 《草图大师》调颜色教程 03-25
- 爱探险的朵拉游戏下载推荐 经典的朵拉游戏排行2026 03-25
- 有趣的4x4越野游戏手机版下载 好玩的越野车游戏合集2026 03-25