具有特殊字符的PHP脚本URL

时间:2014-12-26 10:04:52

标签: php url character inline

我在Wordpress页面中有这个PHP代码

$str = 's.aspx?sm=Q830I7SJZvuSP3HzDfFlVA%3d%3d';

printf('<a href="https://www.surveymonkey.com/.urlencode($str)." target="_blank">
            <img src="http://www.anyfood.gr/net/wp-content/uploads/2014/12/evaluation2.jpg" style="padding:20px;">
       </a>'
);

但链接不起作用,我尝试过使用单引号等几种可能的技巧。 但我无法弄清楚......有什么想法吗?

4 个答案:

答案 0 :(得分:1)

通常,在访问urldecode()参数时,您不必使用GET。使用方法如下:

$str = 's.aspx?sm=' . urlencode ('Q830I7SJZvuSP3HzDfFlVA%3d%3d');

echo '<a href="https://www.surveymonkey.com/'.$str.'" target="_blank">
         <img src="http://www.anyfood.gr/net/wp-content/uploads/2014/12/evaluation2.jpg" style="padding:20px;">
     </a>';

答案 1 :(得分:1)

$str = 's.aspx?sm=Q830I7SJZvuSP3HzDfFlVA%3d%3d';

printf('
 *<*a href="https://www.surveymonkey.com/".urlencode($str) target="_blank">
    *<*img src="http://www.anyfood.gr/net/wp-content/uploads/2014/12/evaluation2.jpg" style="padding:20px;">
  </a>
');

**删除锚点标记和图像标记**

的起始处的*

答案 2 :(得分:1)

试试这个,它对我有用:

<?php
$str = 's.aspx?sm=Q830I7SJZvuSP3HzDfFlVA%3d%3d';

printf('<a href="https://www.surveymonkey.com/%1$s " target="_blank"> <img src="http://www.anyfood.gr/net/wp-content/uploads/2014/12/evaluation2.jpg" style="padding:20px;"> </a>', urlencode($str));
?>

答案 3 :(得分:1)

$str = 's.aspx?sm=Q830I7SJZvuSP3HzDfFlVA%3d%3d';

printf('< a href="https://www.surveymonkey.com/%s" target="_blank">
            <img src="http://www.anyfood.gr/net/wp-content/uploads/2014/12/evaluation2.jpg" style="padding:20px;">
       </ a>', urlencode($str));

检查一下。