<?php
header('Content-Type: text/html; charset=utf-8');
define ('ROOT', $_SERVER['DOCUMENT_ROOT']);
include ROOT.'/assets/php/head.php';
/**
* explode() 函数把字符串打散为数组。
* eval() 函数把字符串按照 PHP 代码来计算。
* */
$val='60 50+80 06+40*30';
$bool = true;
$type = '';
mill($val);
//磨粉机
function mill($val){
$vals = explode(' ',$val);
print_r($vals);
$a = evev($vals[0]);
echo '<br>'.$vals[0].'=';
echo $a;
$b = evev($vals[1]);
echo '<br>'.$vals[1].'=';
echo $b;
$c = evev($vals[2]);
echo '<br>'.$vals[2].'=';
echo $c;
}
function evev($num){
$result = eval("return $num;");
return $result;
}
?>
<?php include ROOT.'/assets/php/foot.php';
//查改样式
$chck = array();
chck($chck);
?>
Array ( [0] => 60 [1] => 50+80 [2] => 06+40*30 )
60=60
50+80=130
06+40*30=1206
标签:60,return,echo,explode,evev,eval,vals,PHP
From: https://www.cnblogs.com/onestopweb/p/18206530