PHP 阻止 htmlspecialchars 转换 URL 中的数字
我有这个网址,我需要将其传递给浏览器并希望对其进行编码。但是,我的 url 字符串中的数字也会被转换,从而导致问题。
这是我的字符串。
"http://domain.com/?w=132&h=132&zc=1&q=90&a=c"
如果我使用 htmlspecialchars,它会将 132 转换为 100,这是错误的。如何预防呢?
更新:也许我应该提到我的字符串看起来像这样,因为我正在使用 timthumb 脚本。
另外我什至不确定我是否需要编码任何东西?或者我提供的网址安全吗?
I have this url which I need to pass to the browser and would like to encode it. However I have numbers in the url string which also gets converted and thus causes issues.
Here is my string.
"http://domain.com/?w=132&h=132&zc=1&q=90&a=c"
And if i use htmlspecialchars, it would convert both 132 to 100 which is wrong. How to prevent that?
UPDATE: perhaps I should mention that my string looks like that because I am using timthumb script.
Also I am not even sure if I need to encode anything? or is the URL i provided safe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我错了请原谅我,但是你不应该使用 urlencode 吗?
urlencode()
?PHP.net 参考
Forgive me if I'm wrong, but shouldn't you use urlencode instead?
urlencode()
?PHP.net reference
htmlspecialchars
不会影响数字...我不知道你在做什么来得到它...无论如何,只要通过
urlencode()
htmlspecialchars
doesn't affect numbers... I have no idea what you're doing to get that...Anyway, just pass it through
urlencode()
htmlspecialchars() 仅转换 5 个字符:
它不接触数字、字母、或其他符号。
htmlspecialchars() only converts 5 characters:
It doesn't touch numbers, letters, or other symbols.