脚本宝典收集整理的这篇文章主要介绍了HREF调用PHP函数并传递变量?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<?PHP function sample(){ foreach ($json_output->object ){ $name = "{$object->tITle}"; $id = "{$object->id}"; PRint "<a href='seArch($id)' >$name</a>"; } } function search($id){ //run a search via the id provide by the clicking of that particular name link } ?>
例如,www.GOOGLE.COM/search.htML?term = blah
将转到www.google.com/search.html,并将传递GET变量“term”,其值为“blah”.
多个变量可以用&分隔.
例如,www.google.com/search.html?term = blah& term2 = cool
PHP通过自动创建超全局变量$_GET []轻松处理GET请求,其中每个数组索引都是GET变量名,数组索引的值是变量的值.
这是一些演示代码,用于说明其工作原理:
<?PHP //check if the get VARiable exists if (isset($_GET['search'])) { search($_GET['search']); } function Search($res) { //real search code goes here echo $res; } ?> <a href="?search=15">Search</a>
以上是脚本宝典为你收集整理的HREF调用PHP函数并传递变量?全部内容,希望文章能够帮你解决HREF调用PHP函数并传递变量?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。