Why “\” gives error while storing it in string in PHP?

前端 未结 4 1192
灰色年华
灰色年华 2021-01-22 12:40

My string looks like:

$fullPath = $dirName . \"/\" . $file;

If I replace / with \\, it gives error:

Expecting identifier

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 12:59

    You might use apostrophes to denote a non-parsed string:

    $fullPath = $dirName . '\' . $file;
    

提交回复
热议问题