在CakePHP中转义URL帮助程序

时间:2016-11-20 13:12:34

标签: php cakephp-3.0

我需要发送带有链接的文本电子邮件,供用户点击。这是用户验证电子邮件。我遇到的问题是URL帮助程序不断转义字符。我觉得我已经在所有可能的组合中尝试过以下但无济于事。

echo $this->Url->build([
    "controller" => "Users",
    "action" => "verify", 
    "?" => ['email' => $email, 'hash' => $hash]  
    ],[
    "escape" => false,
    "fullBase" => true
    ]);

这导致http://www.mydomain.co.uk/users/verify?email=chris%40domain.co.uk&hash=b56a4eea3b495db226888f2f89e7678f所在的'@'和'&' charachters正在逃脱。

另一个问题是,蛋糕无法访问哈希变量,但它可以是电子邮件,即

echo $this->request->query('hash') //doesn't print anything
echo $this->request->query('email') //prints email with the @ symbol

1 个答案:

答案 0 :(得分:0)

感谢Greg Schmidt指出版本不一致。

FYI;您只能使用CakePHP 3.3.5及更高版本的转义(截至2016年11月)。

我使用了htmlspecialchars_decode($ this-> Url-> build())来解决问题

相关问题