如何对带有变量的URL进行URLENCODE编码?

4

我需要对此进行URL编码:

<?php echo 'chart.php?api_url=http://0.chart.apis.google.com/chart?'.$chart1title.$chart1type.$chart1size.$chart1barsize.$chart1gridlines.$chart1data.$chart1color.$chart1bgcolor.$chart1visibleaxis.$chart1axislabels.$chart1axisdatascale.$chart1axisranges.'alt="answeredcalls"';?>

然后在另一端解码它。我该怎么做?


urlencode和urldecode函数适合吗? - spbfox
2个回答

6
'chart.php?api_url=' . urlencode('http://0.chart.apis.google.com/chart?'.$chart1title.$chart1type.$chart1size.$chart1barsize.$chart1gridlines.$chart1data.$chart1color.$chart1bgcolor.$chart1visibleaxis.$chart1axislabels.$chart1axisdatascale.$chart1axisranges.'alt="answeredcalls"');

0
通常在 PHP 中访问 $_GET 参数时,您不需要使用 urldecode() 函数。它会自动为您解码。
前面的答案是该问题编码部分的好解决方案。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接