Home > Backend Development > PHP Tutorial > 字符串转成 数值计算的有关问题

字符串转成 数值计算的有关问题

WBOY
Release: 2016-06-13 12:54:58
Original
848 people have browsed it

字符串转成 数值计算的问题
$num1="1";
$num2="3"
$str="*"

要得出 1*3=3
即:$res=$num1如何$str如何$num2=3
用什么方法


------解决方案--------------------
$res= eval("return $num1$str$num2;");<br />
var_dump($res);
Copy after login
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