phpbackslash

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?


Solution

  • '\' is a special character. Try instead:

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