Ben Davidow
Ben Davidow

Reputation: 1215

'Unescaping' strings in PHP

Simple question. I have a program that uses AJAX to send data from an HTML form to a PHP script that creates a PDF. If a user inputs a value on the HTML form that has an apostrophe it's encoded/escaped with a backslash. For instance, 'Joe's' becomes 'Joe\s'

How can remove the backslash? I suppose I could use str_replace('\', '', $input) but I'm wondering what a broader approach to 'unescaping' a string is in PHP.

Upvotes: 0

Views: 103

Answers (2)

Quentin
Quentin

Reputation: 943510

Normal use of Ajax will not add slash characters to data.

The most likely source of them is magic quotes (which are evil). Turn them off.

Upvotes: 3

spacebean
spacebean

Reputation: 1554

Just use stripslashes($input);

Upvotes: 0

Related Questions