最新下载
热门教程
- 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-16
- 笔趣阁高干文精品入口-笔趣阁2026新址速递 03-16
- 虎牙网页版直达-虎牙直播网页版官方入口 03-16
- 虫虫漫画-免费海量正版漫画在线观看 03-16
- 俄罗斯搜索引擎入口yandex免登录-Yandex俄罗斯搜索免登录入口 03-16
- 妖精漫画最新版下载入口在哪-2026官方安装地址与免费漫画阅读指南 03-16