dongyanpai2701 2016-08-04 12:51
浏览 15
已采纳

PHP url变量给出空白结果[重复]

This question already has an answer here:

I am trying to pass a variable to PHP page using URL GET but I get blank space, what is wrong?!

url: http://localhost:2651/index_main.php?teamName=Liverpool

here is the destination PHP file:

<?php
  $teamName = $_GET['teamName'];
?>
<html>
<body>
<?php
$searchQuery = $api->searchTeam(urlencode('<?php $_GET["teamName"]; ?>')) // here must get the team name from previous page
?>
<h3>All home matches of <?php echo $team->_payload->name; ?>:</h3>
</body>
</html>
</div>
  • 写回答

1条回答 默认 最新

  • douqin1932 2016-08-04 12:58
    关注

    First, your code is not clean, you use too many php tags. Here is your code now :

    <html>
    <head>
    
    </head>
    <body>
        <?php
        $teamName = $_GET['teamName'];
        $searchQuery = $api->searchTeam(urlencode($teamName)); // here must get the team name from previous page
        ?>
        <h3>All home matches of <?php echo $team->_payload->name; ?>:</h3>
    </body>
    </html>
    

    Second, in your urlencode, you put additional php tags and you didn't use the variable you just set before.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料