简体   繁体   English

具有特殊字符的PHP脚本URL

[英]Php script url with special characters

I have this php code in a Wordpress page 我在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>'
);

but the link doesn't work, I've tried several possible tricks using single quotes, etc. but I can't figure it out...Any ideas? 但链接不起作用,我尝试过使用单引号等几种可能的技巧,但我无法弄清楚......有什么想法吗?

Generally you won't have to use urldecode() when accessing GET parameters. 通常,在访问GET参数时,您不必使用urldecode() Use it as follow: 使用方法如下:

$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>';
$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>
');

**remove the * at the starting of Anchor tag and image tag ** **在Anchor标签和图片标签的开头删除*

Try this, it worked for me: 试试这个,它对我有用:

<?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));
?>
$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));

check this. 检查一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM