Alexandru Toma
Alexandru Toma

Reputation: 15

How to write a backslash in a string?

I have this code:

echo str_replace('\', '', $query);

But this generates an error.

Parse error: syntax error, unexpected single-quoted string ", ", expecting ")"

How do I replace a backslash?

Upvotes: 0

Views: 167

Answers (1)

Moatez
Moatez

Reputation: 91

'\' is a special character. Try instead:

echo str_replace('\\','',$query);

Upvotes: 3

Related Questions