这个PHP代码有什么问题?任何人都可以帮助我

时间:2014-11-24 09:38:27

标签: php html

我在www.codeacademy.com在线php编辑器中使用了以下代码。它不打印我想要的输出。请告诉我我犯错的地方

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
    <form action="index.php" method="POST">
    <input type= "text" name="num">
<input type="submit" name="submit">
</form>
        <p>
          <?php
          if(isset($_POST['submit']))
          {
             $type=$_POST['num'];
             echo "$type";
             }



          ?>
        </p>
    </body>
</html>

2 个答案:

答案 0 :(得分:0)

尝试使用echo $ type而不是echo&#34; $ type&#34 ;;

如果它不起作用,则替换action =&#34; index.php&#34;行动=&#34;&#34;

答案 1 :(得分:-1)

我在我的apache服务器上测试过,工作正常。只需将代码存储在index.php中,并使用http:// not file://

调用它