I saw a calculator written in PHP on the Internet, but it cannot achieve calculation output. Please help!
季风
季风 2018-04-25 17:05:33
0
3
1516

如题,源码如下

<!DOCTYPE html>

<html>

<head>

    简易计算器

</head>

<body>   

<?php

    $num1 = $_GET["num1"];

    $num2 = $_GET["num2"];

    if($_GET["ysf"]==" ")

        $sun = $num1 $num2;

    if($_GET["ysf"]=="-")

        $sun = $num1-$num2;

    if($_GET["ysf"]=="*")

        $sun = $num1*$num2;

    if($_GET["ysf"]=="/")

        $sun = $num1/$num2;

?>

<form action="" method="get">

        <input type="text" name="num1"></input>

        <select name="ysf">

            <option value=" "> </option>

            <option value="-">-</option>

            <option value="*">*</option>

            <option value="/">/</option>

        </select>

        <input type="text" name="num2"></input>

        <input type="submit" value="计算" name="sub" />

</form>

 

<?php

    if(isset($_GET["sub"]))

        echo $sun;

?>

 

</body>

</html>


季风
季风

reply all(2)
猪哥

There is no problem after reading the code. The final output is

<?php
    if(isset($_GET["sub"]))
        echo $sun;
?>


无忌哥哥

Look at what the error is

  • reply No error was reported, but the final calculated result was not displayed. Did I miss something?
    季风 author 2018-04-26 14:38:23
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template