php php从url获取数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11790863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php Get data from url
提问by user1411837
I have a system where in users can create forms dynamically. Once the form is created a unique URL is generated and stored in the database . These URL's are for calling the form back when the users type it out in the browser .
我有一个系统,用户可以在其中动态创建表单。一旦创建了表单,就会生成一个唯一的 URL 并将其存储在数据库中。这些 URL 用于在用户在浏览器中输入表单时回调表单。
Now i want a particular file to read the url when the users type out the generated url in the browser , so that i can get the last segment of the url which is unique and fetch the respective data at run time .
现在我想要一个特定的文件在用户在浏览器中输入生成的 url 时读取 url,这样我就可以获得 url 的最后一段,这是唯一的,并在运行时获取相应的数据。
I cant seem to figure out how to do that .
我似乎无法弄清楚如何做到这一点。
回答by VictorKilo
If you are trying to receive data from a URL string, you will need to use the $_GETvariable .
如果您尝试从 URL 字符串接收数据,则需要使用$_GET变量 。
If the url is http://domain.com/page.php?var1=some-string
如果网址是 http://domain.com/page.php?var1=some-string
You would retrieve var1like so:
你会var1像这样检索:
<?php
$var1 = $_GET['var1'];
echo $var1; //would output "some-string"
?>
Is this what you're asking or is it something more in-depth?
这是您要问的问题还是更深入的问题?

