PHP;如何在 $POST 之后用 issest 对变量求和
PHP; how do I sum a variable after $POST with issest
我有一个包含一些变量的大文件,我想在它们 POST.
之后求和(添加)
请注意,我是在 TCPDF 中执行此操作的。我不知道这是否有所作为。尽管如此,我试图求和的变量是通过 isset 函数发布的。发布变量后,我声明了一个新变量。示例 $sum = $two+$three+$four+$five;
。但是,当我这样做时,出现未定义变量错误。理想情况下,我想声明一个新变量,该变量采用求和值并将它们放在我的 TCPDF 文件中的 HTML 字符串中。例如
总计:$sum
//var_dump($_POST);
if (isset($_POST)) {
if(isset($_POST['two'])){ $two = $_POST['two'];}else{$two = " ";}
if(isset($_POST['three'])){ $three = $_POST['three'];}else{$three = " ";}
if(isset($_POST['four'])){ $four = $_POST['four'];}else{$four = " ";}
if(isset($_POST['five'])){ $five = $_POST['five'];}else{$five = " ";}
if(isset($_POST['six'])){ $six = $_POST['six'];}else{$six = " ";}
if(isset($_POST['seven'])){ $seven = $_POST['seven'];}else{$seven = " ";}
if(isset($_POST['eight'])){ $eight = $_POST['eight'];}else{$eight = " ";}
if(isset($_POST['nine'])){ $nine = $_POST['nine'];}else{$nine = " ";}
if(isset($_POST['ten'])){ $ten = $_POST['ten'];}else{$ten = " ";}
if(isset($_POST['elve'])){ $elve = $_POST['elve'];}else{$elve = " ";}
if(isset($_POST['twelv'])){ $twelv = $_POST['twelv'];}else{$twelv = " ";}
也许一次尝试一个。它很乏味,但我认为它可能有用。
$sum = $one + $two;
$sum = $sum +$three;`
`
我有一个包含一些变量的大文件,我想在它们 POST.
之后求和(添加)请注意,我是在 TCPDF 中执行此操作的。我不知道这是否有所作为。尽管如此,我试图求和的变量是通过 isset 函数发布的。发布变量后,我声明了一个新变量。示例 $sum = $two+$three+$four+$five;
。但是,当我这样做时,出现未定义变量错误。理想情况下,我想声明一个新变量,该变量采用求和值并将它们放在我的 TCPDF 文件中的 HTML 字符串中。例如
总计:$sum
//var_dump($_POST);
if (isset($_POST)) {
if(isset($_POST['two'])){ $two = $_POST['two'];}else{$two = " ";}
if(isset($_POST['three'])){ $three = $_POST['three'];}else{$three = " ";}
if(isset($_POST['four'])){ $four = $_POST['four'];}else{$four = " ";}
if(isset($_POST['five'])){ $five = $_POST['five'];}else{$five = " ";}
if(isset($_POST['six'])){ $six = $_POST['six'];}else{$six = " ";}
if(isset($_POST['seven'])){ $seven = $_POST['seven'];}else{$seven = " ";}
if(isset($_POST['eight'])){ $eight = $_POST['eight'];}else{$eight = " ";}
if(isset($_POST['nine'])){ $nine = $_POST['nine'];}else{$nine = " ";}
if(isset($_POST['ten'])){ $ten = $_POST['ten'];}else{$ten = " ";}
if(isset($_POST['elve'])){ $elve = $_POST['elve'];}else{$elve = " ";}
if(isset($_POST['twelv'])){ $twelv = $_POST['twelv'];}else{$twelv = " ";}
也许一次尝试一个。它很乏味,但我认为它可能有用。
$sum = $one + $two;
$sum = $sum +$three;`
`