<?php
header('Content-Type: text/html; charset=utf-8');
include './assets/php/head.php';
/**
* 第一个计算长方体的体积公式
* 已知长是40-10,宽是30+20,高是35*2
* 求长方体的体积
* */
$val='40-10 30+20 35*2';
$vals = explode(' ',$val);
$a = evev($vals[0]);
$b = evev($vals[1]);
$h = evev($vals[2]);
$know = array();
array_push($know, $val);
array_push($know, "长:$a {$math['eq']} {$vals[0]}");
array_push($know, "宽:$b {$math['eq']} {$vals[1]}");
array_push($know, "高:$h {$math['eq']} {$vals[2]}");
$abcd = array();
array_push($abcd, "{$math['eq']} $a{$math['mul']}$b{$math['mul']}$h");
$ab = bcmul($a,$b);
array_push($abcd, "{$math['eq']} $ab{$math['mul']}$h");
$abh = bcmul($ab,$h);
array_push($abcd, "{$math['eq']} $abh");
$ends = array();
array_push($ends, "长方体的体积是 $abh");
$from = array();
array_push($from, "V=abh");
$info = array();
array_push($info, "长方形的体积 等于 长 乘以 宽 乘以 高。");
know($know);
ends($ends);
from($from);
abcd($abcd);
info($info);
//eval计算 evev
function evev($num){
$result = eval("return $num;");
return $result;
}
//已知条件 know
function know($arr){
echo '<br>已知条件:<br>';
foreach ( $arr as $value ) {
echo $value.'<br>';
}
}
//运算结果 ends
function ends($arr){
echo '<br>运算结果:<br>';
foreach ( $arr as $value ) {
echo $value.'<br>';
}
}
//参考公式 from
function from($arr){
echo '<br>参考公式:<br>';
foreach ( $arr as $value ) {
echo $value.'<br>';
}
}
//运算过程 abcd
function abcd($arr){
echo '<br>运算过程:<br>';
foreach ( $arr as $value ) {
echo $value.'<br>';
}
}
//公式说明 info
function info($arr){
echo '<br>公式说明:<br>';
foreach ( $arr as $value ) {
echo $value.'<br>';
}
}
?>
<?php include './assets/php/foot.php'; ?>
结果: