Php 使用解析变量计算
这是一个使用php变量和解析的计算器。在url中输入变量与在表单中输入变量是一样的。当我点击提交时,它应该会计算。但我不知道哪里不对(没有正确分配变量?)非常感谢 以下是我的问题: 1。我应该在哪里修正它才能正确计算? 2.如何通过在表单中输入页面的实际表格填充和表格边框来更改它们? 3.如何使用从URL传递的变量更改表格的背景颜色?Php 使用解析变量计算,php,parsing,variables,calculator,Php,Parsing,Variables,Calculator,这是一个使用php变量和解析的计算器。在url中输入变量与在表单中输入变量是一样的。当我点击提交时,它应该会计算。但我不知道哪里不对(没有正确分配变量?)非常感谢 以下是我的问题: 1。我应该在哪里修正它才能正确计算? 2.如何通过在表单中输入页面的实际表格填充和表格边框来更改它们? 3.如何使用从URL传递的变量更改表格的背景颜色? <?php // parse variables from URLs echo "This is the value of <b>x:</
<?php
// parse variables from URLs
echo "This is the value of <b>x:</b> " . $_GET['x'] . ". This is the value of <b>y: </b> " . $_GET['y'] . ".This is the value of <b>z: </b> " . $_GET['z'] . " , And the title is: " . $_GET['title'] . ".";
?>
<?
$result1 = $x + $y - 2*$z;
$result2 = 2*$x + 4*$y + (3*$z - 80);
$result3 = $result1 + $result2;
?>
<center><h2> Math </h2></center>
<center>
<table cellpadding=20 border=20 bgcolor=#00ffff >
<tr>
<td><b>Mathematical Operation</b></td>
<td><b>Result</b></td>
</tr>
<tr>
<td>x + y - 2 * z</td>
<td><?echo "$result1";?></td>
</tr>
<tr>
<td>2x - 4y + (3z - 80)</td>
<td><?echo "$result2";?></td>
</tr>
<tr>
<td>Row2 - Col2 + result of Row3 - Col2</td>
<td><?echo "$result3";?></td>
</tr>
</table>
</center>
<form>
<u>Inputs:</u> <br />
X-value <input type="text" name="x" value=""></input><br />
Y-Value <input type="text" name="y" value=""></input><br />
Z-Value <input type="text" name="z" value=""></input><br />
Title <input type="text" name="title" value=""></input><br />
Table Padding <input type="text" name="pad" value=""></input><br />
Table Border <input type="text" name="brdr" value=""></input><br />
Background Color <input type="color" name="bckrd" value=""></input><br />
<input type="submit" name="submit" value="SUBMIT and CALCULATE"></input>
</form>
<?
if ($_GET['submit']) {
$result1 = $x + $y - 2*$z;
$result2 = 2*$x + 4*$y + (3*$z - 80);
$result3 = $result1 + $result2;
}
?>
数学
数学运算
结果
x+y-2*z
2x-4y+(3z-80)
第2行-Col2+第3行-Col2的结果
输入:
X值
Y值
Z值
标题
表格填充
表格边框
背景色
$x=$\u GET['x']代码>
$y=$\u GET['y']代码>
$z=$\u GET['z']代码>
$result1=$x+$y-2*$z代码>
$result2=2*$x+4*$y+(3*$z-80)代码>
$result3=$result1+$result2代码>
填充:
边框宽度:
颜色:
$tblPadding = $_GET['tblpadding'];
$tblWidth = $_GET['tblwidth'];
$tblColour = $_GET['tblcolour'];
然后,将您的
声明更改为:
很抱歉格式化太糟糕,无法确定如何正确格式化列表项中的整个代码块,缩进似乎不起作用:/