doufang1954 2015-11-03 23:03
浏览 40

PHP - 从URL输入字符串?

Is it possible to input the string from the url in the code.

"http://website.com?ip=123.com"

 $statut = file_get_contents('http://www.example.com/index.php?Etat_Query&ip=',$ip,'&port=25565');

i want $ip to be replaced with the variable 123.com from the URL.

(Sorry my english is not the best)

  • 写回答

1条回答 默认 最新

  • doumiang2297 2015-11-03 23:06
    关注

    Of course it is possible but you have to URL Encode your ip variable in the URL using this :

    $encoded = urlencode('123.com');
    

    For your specific example it's not necessary but if the URL is more complicated (like using '&'...) it will be necessary.

    Then your $ip variable would just be :

    $ip = $_GET['ip'];
    

    Let me just warn you about a security issue that could occur using this method, like malicious php script that could be downloaded to your server.

    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀