Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取PHP上的查询url_Php_Url_Curl - Fatal编程技术网

获取PHP上的查询url

获取PHP上的查询url,php,url,curl,Php,Url,Curl,我有这个urlhttp://www.mywebsite.com/code.php?number=1234233566456766或 http://www.mywebsite.com/code.php?1234233566456766如果第一个示例不可行, 我试着在上获取代码,看一下。它接受一个URL作为输入,并返回一个包含所有独立部分的数组 文档中稍作修改的示例: $url = 'http://username:password@example.com/path?arg=value#anchor

我有这个url
http://www.mywebsite.com/code.php?number=1234233566456766
http://www.mywebsite.com/code.php?1234233566456766
如果第一个示例不可行, 我试着在
上获取代码,看一下。它接受一个URL作为输入,并返回一个包含所有独立部分的数组

文档中稍作修改的示例:

$url = 'http://username:password@example.com/path?arg=value#anchor';

print_r( parse_url( $url ) );
产出:

Array
(
    [scheme] => http
    [host] => example.com
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)

我相信您正在查找URL的
查询
部分。从那里,您可以使用将该字符串拆分为变量。

什么数字后面的文本??数字-->后面的文本->1234233566456766以及如何解析我的url?对不起,那些蓝色文本是链接。您可能希望单击它们这是假设OP不仅仅处理碰巧是URL的字符串。它可以是保存在DB中的字符串。
//first, check number through GET
if(isset($_GET['number'])){
 $text = $_GET['number'];
}else{
 //second, check REQUEST_URI
 $urlparts = parse_url( $_SERVER['REQUEST_URI']);
 $text = $urlparts['query'];
}
echo $text;