使用HTML链接将PHP GET数据发送到服务器 [英] Sending PHP GET data to server using Html links

查看:56
本文介绍了使用HTML链接将PHP GET数据发送到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段时间没有写PHP GET请求了。所以我有点生锈。但是,如何使用HTML链接发送GET数据。如果我使用jQuery的get方法,我知道该怎么做,但是我只是想知道在HTML中使用href或其他类似方法是否更简单。

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.

推荐答案

将参数放在网址后面:

index.php?param1=yes&param2=no

然后,您可以在 $ _ GET

echo $_GET['param1'];

但这是PHP的基础知识。也许您应该先阅读文档

But this are PHP basics. Perhaps you should read the documentation before.

在jQuery中使用ajax请求相同。您可以将参数放在网址后面。

In jQuery with an ajax request its the same. You can put your parameters behind the url.

$.get('index.php?param1=yes&param2=no', function(data) {
  $('.result').html(data);
  alert('Load was performed.');
});

如果要读取所有GET参数,可以使用foreach循环。

If you want to read all GET Parameters you can use a foreach loop.

foreach($_GET as $key => $value) {
    echo $key.":".$value;
}

这篇关于使用HTML链接将PHP GET数据发送到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆