我无法想象如何使这个PHP形式工作

-1 php forms simple-form

我无法想象如何使这个简单的PHP表单起作用.我做错了什么?

  <?php
$first = "firstNumber";
$second = "secondNumber";
$second * $first = "calc";
$calc = "calc";
echo("" . $_GET['$calc'] . "<br />\n");
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
        <form action="new.php" method="get">
        <input type="text" name="firstNumber" id="first">
        <input type="text" name="secondNumber" id="second">
        <input style="background-color: #0094ff;" type="submit" name="calc" value="???" id="second">
        </form>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

Ron*_*den 6

简而言之

我想你想要的东西

<?php
$first = $_GET["firstNumber"];
$second = $_GET["secondNumber"];
$calc = $second * $first;
echo $calc . "<br />";
?>
Run Code Online (Sandbox Code Playgroud)

扩展

但是完整的,因为如果你运行它,你会收到警告,因为你没有发送表格

<?php
   if(isset($_GET['calc'])) {
      $first = $_GET["firstNumber"];
      $second = $_GET["secondNumber"];
      $calc = $second * $first;
      echo $calc . "<br />";
   }
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
        <form action="new.php" method="get">
        <input type="text" name="firstNumber" id="first">
        <input type="text" name="secondNumber" id="second">
        <input style="background-color: #0094ff;" type="submit" name="calc" value="???" id="second">
        </form>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

http://codepad.viper-7.com/LZ7phd