Home > Backend Development > PHP Tutorial > PHP 字符串轮换后不能运算

PHP 字符串轮换后不能运算

WBOY
Release: 2016-06-13 11:10:42
Original
825 people have browsed it

PHP 字符串替换后不能运算
由于把公式写在数据库中:
如 $gongshi="a+b+c";
前台做替换
如a=3;b=4;c=5;
$gongshi=str_ireplace("3","a",$gongshi);
$gongshi=str_ireplace("4","b",$gongshi);
$gongshi=str_ireplace("5","c",$gongshi);
替换成功
3+4+5不能自动计算,该怎么办?


------解决方案--------------------
eval()
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template