Otag
Otag

Reputation: 143

how to escape special characters in a path PHP

I checked the internet and stackoverflow for a reliable answer but to no avail. My question is this => Consider the following path name

D:\folder1\folder2\filli.pgn 

or

D:\folder1\folder2\roklu.pgn

Now the \f and the \r here cause problems and give rise to errors. There are many special characters in PHP beside these. How can I escape all of them. Surely there must be a way... Thank you

Upvotes: 1

Views: 655

Answers (1)

Chris
Chris

Reputation: 5876

You can escape the slash by putting a slash before it. This will prevent the next character from being treated as part of an escape sequence. e.g.

D:\\folder1\\folder2\\roklu.pgn

Upvotes: 3

Related Questions