dsf12123 2017-09-19 10:47
浏览 17
已采纳

在变量之后抓取所有文本

I'm a little unsure of how to word this one but essentially, I want to achieve the following:

http://my.website/?url=http://another.website/?var1=data&var2=moredata&id=119

And for the URL variable to be: http://another.website/?var1=data&var2=moredata&id=119

Naturally, PHP sees var2 and id as new variables. This would be used to pass a full URL from one page to another, however, it poses an issue when the page already has its own variables in the URL!

Any help appreciated!

  • 写回答

1条回答 默认 最新

  • dragon2025 2017-09-19 10:54
    关注

    You need to encode the secondary url which you're putting inside the url variable when you create it. This will ensure it doesn't contain special querystring characters that the receiving website will misunderstand. If the code in my.website is PHP too then the urlencode function (http://php.net/manual/en/function.urlencode.php) is your friend. For example:

    urlencode("http://another.website/?var1=data&var2=moredata&id=119")
    

    produces

    http%3A%2F%2Fanother.website%2F%3Fvar1%3Ddata%26var2%3Dmoredata%26id%3D119
    

    which will not be misunderstood by the PHP code reading it as containing further separate variables.

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

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能