%0d%0a被添加到<a> tag

时间:2016-02-14 08:19:18

标签: php html wordpress woocommerce

In a helper plugin for WooCommerce for WordPress, I'm trying to create a custom message to be sent to a buyer.

I don't know why in all the emails that are sent out, %0d%0a is getting added behind the URL in the href attribute. I have tried several different combinations and nothing is working.

This is what I'm trying to do:

echo "<a href='$cl'> Please click here to redeem the coupon</a>";

But because %0d%0a is being added at the back of it the URL doesn't work properly for coupon codes.

This is what the URL looks like afterwards:

https://www.example.com/product-1/?couponCode=TDXGUA9G&utm_source=test&utm_medium=testt&utm_campaign=test&aff_code=TSJU89XYZ%0d%0a

中href属性的网址后面

唯一没有添加%0d%0a的是:

 echo $cl;

但我希望能够使用<a>代码,以便买家无需点击长网址链接。

3 个答案:

答案 0 :(得分:0)

试试这个

echo "<a href='" . $cl . "'> Please click here to redeem the coupon</a>";

如果您仍有问题,请检查$cl的创建方式。

答案 1 :(得分:0)

我非常感谢所有回复。但我只是想在7个小时的工作后发布最终为我工作的代码。我知道它看起来很傻,但这是我现在能做的最好的事情。这对我有用:

    ?>
    <a href='<?php echo trim($cl); ?>'> <span color="#557da1">Click here to take <?php echo ' '.$_product_name.'</span></a>';

答案 2 :(得分:0)

我刚刚遇到了同样的问题,但是我正在使用ASP.NET。我所做的就是删除单引号,然后再次键入。现在可以了。

<asp:HyperLink ... NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Name") %>' />

可能还有一些多余的不可见字符需要删除。