Home > Article > Backend Development > What to do if the diagonal bar cannot be recognized in PHP
php中斜杆无法识别的解决办法:1、打开相应的代码文件;2、把路径中的反斜杠替换成正斜杠即可正常识别。
本文操作环境:Windows7系统、thinkphp5.0版、DELL G3电脑
php中斜杆无法识别?
thinkphp5.0查询到的数据表中的路径是反斜杠导致无法正常显示图片?
添加到数据表中图片的路径有时会是反斜杠,这就导致了在url后面写路径的时候会识别不出来(不过src后面写路径就可以识别),所以就需要把路径中的反斜杠替换成正斜杠,代码如下:
$datu = Db::query('select images from think_ad where ad_position_id = 22'); $str = ""; foreach($datu as $v) { $str .= implode($v); $str .= "|"; } $str = substr($str,0,strlen($str)-1); $str=str_replace('\\','/',$str); $str = explode("|",$str); $this->assign('datu',$str);
推荐学习:《PHP视频教程》
The above is the detailed content of What to do if the diagonal bar cannot be recognized in PHP. For more information, please follow other related articles on the PHP Chinese website!