Php mailto:subject=的urlencode()字符串,带有可以正确解码的破折号字符
我有一个字符串,例如“2013国际卡车–XZ1234”,我需要对其进行urlencode(),并以正确解码的方式将其包含在mailto subject=中。我已通过以下方式对此进行了测试:Php mailto:subject=的urlencode()字符串,带有可以正确解码的破折号字符,php,mailto,Php,Mailto,我有一个字符串,例如“2013国际卡车–XZ1234”,我需要对其进行urlencode(),并以正确解码的方式将其包含在mailto subject=中。我已通过以下方式对此进行了测试: $encodedstring = urlencode("mailto:info@something.com?subject=2013 International Truck – XZ1234") <a href="<?php $encodedstring ?>">Email Us<
$encodedstring = urlencode("mailto:info@something.com?subject=2013 International Truck – XZ1234")
<a href="<?php $encodedstring ?>">Email Us</a>
是否有一种替代urlencode()或其他方式来编码此字符串,以便在邮件客户端中正确解码所有字符,包括破折号?您的字符串正在进行双重编码
%26%238211%3B
是和#8211的编码形式代码>,这是破折号的编码形式。跟踪代码的执行情况,查看代码的编码位置两次。您可以使用以下命令删除特殊格式
remove_filter( ‘the_title’ , ‘wptexturize’ );
remove_filter( ‘the_content’ , ‘wptexturize’ );
remove_filter( ‘the_excerpt’ , ‘wptexturize’ );
remove_filter( ‘comment_text’ , ‘wptexturize’ );
remove_filter( ‘list_cats’ , ‘wptexturize’ );
这似乎不像urlencode()单独做的事情。您是否1000000%确定在您的代码中某处没有调用htmlentities()
?您是对的@Pekka웃. 我没有意识到我正在编码的变量首先通过Wordpress的标题()应用了htmlentities()
。成功了!谢谢我在Wordpress中使用了标题()
,我需要将其更改为html实体解码(获取标题())
2013 International TerraStar Truck – NT2031
remove_filter( ‘the_title’ , ‘wptexturize’ );
remove_filter( ‘the_content’ , ‘wptexturize’ );
remove_filter( ‘the_excerpt’ , ‘wptexturize’ );
remove_filter( ‘comment_text’ , ‘wptexturize’ );
remove_filter( ‘list_cats’ , ‘wptexturize’ );