Correct syntax for hyperlink URL with PHP $_GET

大城市里の小女人 提交于 2019-12-28 06:52:25

问题


I am wondering how I would put information from my website in the URL on the first page of my site, and then on the next page, use $_GET to get the variables from the URL.

I was just wanting to put it in a link like <a href="mywebsite.com/page?name=$name"></a> So would it work if I did it like that, and if it would, how would I get it from the URL?


回答1:


do

<a href="http://mywebsite.com/page?name=<?php echo $name; ?>"></a>

And in your page, you could get the name as:

$name = $_GET['name'];



回答2:


Example Link: http://example.com/page.php?name=Charles

If you used $_GET["name"] it would return the value Charles

For more information on $_GET look at http://php.net/manual/en/reserved.variables.get.php




回答3:


the $_GET is the variable. so in this case, to get the name, it would be:

$_GET['name'];


来源:https://stackoverflow.com/questions/13852424/correct-syntax-for-hyperlink-url-with-php-get

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!