如何在没有%20%27的情况下传递变量并准确检索传递的内容我尝试了urlencode和解码但是没有工作需要一些帮助
传入网址http://localhost/civilhelp/enquiry.php?cat=%27PLUMBING%20FITTINGS%20&%20SANITARY%20WARE%27 我需要删除%27%20使用过的urlencode但没有使用
只追回PLUMBING FITTINGS并留下任何人帮助解决方案
我将其作为
传递 $cate = 'PLUMBING FITTINGS & SANITARY WARE'; it is from db
<a href="enquiry.php?cat='<?php echo urlencode($cate) ;?>'">
尝试检索为
$category = urldecode($_GET['cat']);
$category = str_replace("'"," ",$category);
print_r($category);
$category = trim($category);
print_r($category);
它只打印PLUMBING FITTINGS
我没有得到确切的通过 注意:我使用过urlencode和urldecode也修剪了
但我仍然不能希望我的问题是什么!!
答案 0 :(得分:0)
这是不对的我尝试了你的代码并显示正确的数据试试这个
$url = 'http://localhost/civilhelp/enquiry.php?cat=%27PLUMBING%20FITTINGS%20&%20SANITARY%20WARE%27';
$category = urldecode($url);
$category = str_replace("'","",$category);
echo $category; // result: http://localhost/civilhelp/enquiry.php?cat=PLUMBING FITTINGS & SANITARY WARE
编辑:
我只是在cat =&#39;&#39;变化与至%26
答案 1 :(得分:-1)
<?php if(!empty($r['category'])){ $cat = $r['category']; $cate=substr($cat,0,25) . '';
//$cat = str_replace(' ', '', $cate);
$cat = str_replace('&', '%26', $cat); after changing it works fine // print_r($cat);?>
<a href="enquiry.php?cat='<?php echo $cat ;?>'">
enter code here