Home > Backend Development > PHP Problem > What to do if the diagonal bar cannot be recognized in PHP

What to do if the diagonal bar cannot be recognized in PHP

藏色散人
Release: 2023-03-15 06:48:01
Original
1746 people have browsed it

php中斜杆无法识别的解决办法:1、打开相应的代码文件;2、把路径中的反斜杠替换成正斜杠即可正常识别。

What to do if the diagonal bar cannot be recognized in PHP

本文操作环境: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);
Copy after login

推荐学习:《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!

Related labels:
php
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