我只得到“choice”和“cat”的值。请告诉我上面的-6ren">
gpt4 book ai didi

php - 如何在 PHP 的 href 链接中发送多个值?

转载 作者:行者123 更新时间:2023-12-03 21:05:28 24 4
gpt4 key购买 nike

我想使用 href 链接将多个值发送到不同的页面。但是我检索到的只是前两个值,其余显示未定义索引的错误。

我的代码是:

<?php 

echo "<a href='index.php?choice=search&cat=".$cat."&subcat=".$subcat."&srch=".$srch."&page=".$next."'> Next </a>";

?>

我只得到“choice”和“cat”的值。请告诉我上面的代码有什么问题。

最佳答案

尝试使用 urlencode,如果字符串中有任何特殊字符,它可能会对整个查询字符串产生影响;

echo "<a href='index.php?choice=search&cat=".urlencode($cat)."&subcat=".urlencode($subcat)."&srch=".urlencode($srch)."&page=".urlencode($next)."'> Next </a>";

此外,您在 srch 和 page 之间有一个空格,这可能会导致问题。

关于php - 如何在 PHP 的 href 链接中发送多个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11708112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com