Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mailto:subject=的urlencode()字符串,带有可以正确解码的破折号字符_Php_Mailto - Fatal编程技术网

Php mailto:subject=的urlencode()字符串,带有可以正确解码的破折号字符

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<

我有一个字符串,例如“2013国际卡车–XZ1234”,我需要对其进行urlencode(),并以正确解码的方式将其包含在mailto subject=中。我已通过以下方式对此进行了测试:

$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 &#8211; 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’ );