php特殊字符问题
我的脚本中的特殊字符有问题:
这是我到目前为止所遇到的问题:
$curlstrip = explode("&", $data);
$filename = substr(htmlEntities($curlstrip[5]), 2);
如果 $data
包含任何特殊字符,例如 '
是',那么我只得到第一部分,而不是得到我需要的字符串块。 更详细的示例:
$data = "12er&sdsretdgsd&file=Chris ' 19 &blabla"
脚本会将 Chris 之后的 ' 读取为 '
,并且 $curlstrip[5]
将具有不同的值。
希望是足够明确的。
LE。按照这个例子:
$data = "12er&sdsretdgsd&file=Chris ' 19 &blabla"
$curlstrip = explode("&", $data);
$curlstrip[0] = '12er';
$curlstrip[1] = 'sdsretdgsd';
但是
$curlstrip[2] = 'file=Chris' instead of 'file=Chris ' 19'
那是因为 ' 被读作
'
Thx,
Cristian。
I am having a problem with the special characters in my script:
This is what I have so far:
$curlstrip = explode("&", $data);
$filename = substr(htmlEntities($curlstrip[5]), 2);
and if $data
contains any special charaters like '
which is ', then instead of getting the chunk of string that I need, I get only the first part.
A more detailed example:
$data = "12er&sdsretdgsd&file=Chris ' 19 &blabla"
the script will read the ' after Chris as '
and $curlstrip[5]
will have a different value.
Hope is clear enough.
LE. Following this example:
$data = "12er&sdsretdgsd&file=Chris ' 19 &blabla"
$curlstrip = explode("&", $data);
$curlstrip[0] = '12er';
$curlstrip[1] = 'sdsretdgsd';
but
$curlstrip[2] = 'file=Chris' instead of 'file=Chris ' 19'
and that is because the ' is being read as
'
Thx,
Cristian.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
由于给定提供的代码,我无法复制您的错误,因此我有一种预感 - 尝试:
如果出于某种原因,您有 && (两个&符号)在 $data 中彼此相邻出现,它将干扰爆炸功能。
Try:
As I cant replicate your error given the code supplied, I have a hunch- try:
If, for whatever reason, you have && (two ampersands) occurring in $data next to one another, it will interfere with the explode function.
让 htmlentities 成为您对数据调用的最后一个对象。
除此之外,还有一些函数可以处理您正在做的事情。 parse_str 将从查询字符串创建一个数组。 parse_url 可用于从 URL 中提取查询字符串。
Make htmlentities the last thing you call on the data.
Aside from that there are functions to deal with what you're doing. parse_str will create an array from a query string. parse_url can be used to extract the query string from a url.