PHP - escaping special characters... help!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
x135
Forum Newbie
Posts: 1
Joined: Wed Oct 22, 2008 8:44 pm

PHP - escaping special characters... help!!

Post by x135 »

Hi all,

I am in need of the php script to escape special characters out of a text file that has tab seperated data.

Any ideas?

Any help would be most appreciated
maneetpuri
Forum Commoner
Posts: 60
Joined: Tue Oct 07, 2008 6:32 am

Re: PHP - escaping special characters... help!!

Post by maneetpuri »

There is no explicit function for escaping special characters in PHP, but you can use addslashes() to introduce slashes in front of every special character, which would not lead a special character treated as a special character. The antonym of addslashes is stripslashes which removes the slashed pre fixed before every special character in a staring.

And you want to totally remove special characters then you will have to write a small piece of code that will remove all the defined special characters in an array from the string being processed.

Hope this helps!

Cheers,
Post Reply