tags:

views:

76

answers:

4

My string looks like:

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

If I replace / with \, it gives error: "Expecting identifier or variable". I want to store in the latter way itself. How to override anything coming in between?

+1  A: 

u need "\" cause \ is an escape character

interestingly : i cant put \ \ on SO as well .. so just remove the space "\ \"

Sabeen Malik
That's odd, because I could. I'll try it \\ .
Bobby
i tried "\\" and it didnt work .. maybe cause i didnt mark it as code or something
Sabeen Malik
+8  A: 

\ is an escape character. Try \\ .

Bobby
+4  A: 

You need to escape the slash: $fullPath = $dirName . "\\" . $file;

Lukman
A: 

Or wrap \ in single quotes, i.e. '\' since single quotes mean no escaping characters.

dare2be