doujiabing1228 2014-05-06 13:04
浏览 12
已采纳

从URL获取值php获取方法[关闭]

http://sath3g.altervista.org/jsonint.html?id=5678

I have to take the value of id with php. I tried in this way but it doesn't work.

<html>
<head>
</head>
<body>
  <?php
    $variabile_get = $_GET['id']; 
    echo( $variabile_get);
  ?>
</body>
</html>

I don't see nothing. Someone can help me????

  • 写回答

5条回答 默认 最新

  • dsyq40772 2014-05-06 13:09
    关注

    If you want to print variable value in HTML you should always use escape function as for example htmlspecialchars to prevent attack on your site so the code should be:

       <html>
        <head>
        </head>
        <body>
          <?php
            $variabile_get = $_GET['id']; 
            echo htmlspecialchars($variabile_get);  
          ?>
        </body>
        </html>
    

    Of course if you expect that id is int you could also change lines:

            $variabile_get = $_GET['id']; 
            echo htmlspecialchars($variabile_get);  
    

    to

            $variabile_get = intval($_GET['id']); 
            echo $variabile_get;  
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答