好的家伙我在这里遇到了一个情况,我可以帮忙。
我将发送给我的参数url编码,它们看起来像这样
http://example.com/tyntec.php?sender%3D%2B16155305760%26receiver%3D%2B17874539876%26text%3Dplease+stop+sending+messages
我试图设置我的变量,但这不起作用,因为我猜$ _REQUEST正在跳过编码的&登录
$to = $_REQUEST['receiver'];
$from = $_REQUEST['sender'];
$text = $_REQUEST['text'];
如何从URL中正确获取参数并设置变量?
先谢谢你帮助我。
答案 0 :(得分:0)
试试这个。
parse_str( urldecode( 'http://example.com/tyntec.php?sender%3D%2B16155305760%26receiver%3D%2B17874539876%26text%3Dplease+stop+sending+messages' ), $output );
var_dump($output);
答案 1 :(得分:-1)
使用此:
<?php
$url = 'http://example.com/tyntec.php?sender%3D%2B16155305760%26receiver%3D%2B17874539876%26text%3Dplease+stop+sending+messages
';
$url = utf8_decode(urldecode($url));
$parts = parse_url($url);
parse_str($parts['query'], $query);
echo $query['sender'];
echo $query["receiver"];
echo $query["text"];
?>