问题
I haven't wrote PHP GET requests in a while. So I'm a little rusty. But how do I send GET data using an Html link. If I use jQuery's get method's I know how to do it, but I was just wondering if there is a simpler way using the href in Html or something similar.
回答1:
Put the parameters behind the url:
index.php?param1=yes¶m2=no
Then you can read the variables over $_GET
echo $_GET['param1'];
But this are PHP basics. Perhaps you should read the documentation before.
In jQuery with an ajax request its the same. You can put your parameters behind the url.
$.get('index.php?param1=yes¶m2=no', function(data) {
$('.result').html(data);
alert('Load was performed.');
});
If you want to read all GET Parameters you can use a foreach loop.
foreach($_GET as $key => $value) {
echo $key.":".$value;
}
回答2:
The simple ways is,
<a href="page.php?string1=str&string2=str&string3=str"></a>
or a form doing,
<form action="page.php" method="get"></form>
来源:https://stackoverflow.com/questions/11281947/sending-php-get-data-to-server-using-html-links