Home > Backend Development > PHP Tutorial > php json函数输出图片路径有关问题

php json函数输出图片路径有关问题

WBOY
Release: 2016-06-13 12:57:49
Original
891 people have browsed it

php json函数输出图片路径问题
希望高手指点一下,小弟不胜感激,我用php输出一段json,但是不明白为什么单独输出图片路径的时候他是可以正确输出,一旦用json_encode以后他就会多出一些东西代码如下
/*
留言板
*/
$liu=array(array('url'=>'../img/01.jpg','title'=>'三只熊','message'=>'三只熊是我最喜欢的人','timer'=>'2010-06-18'));
echo json_encode($liu);
?>
输出url是有问题的,输出以后是这样的
[{"url":"..\/img\/01.jpg","title":"\u4e09\u53ea\u718a","message":"\u4e09\u53ea\u718a\u662f\u6211\u6700\u559c\u6b22\u7684\u4eba","timer":"2010-06-18"}]
url就多出来了一个\不知道怎么解决!!!谢谢各位高手了

------解决方案--------------------

<br />
<br />
echo str_replace('\/', '/', $data=json_encode($liu));//这样试试,不确定后果<br />
<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template