checking a var for unwanted chars

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
rufee
Forum Newbie
Posts: 10
Joined: Wed Dec 09, 2009 10:23 am

checking a var for unwanted chars

Post by rufee »

Hello
I have a question
How to check a variable for unwanted chars such as " ' ` {}[]()<>/?|" and so on?
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: checking a var for unwanted chars

Post by JNettles »

Regex.
rufee
Forum Newbie
Posts: 10
Joined: Wed Dec 09, 2009 10:23 am

Re: checking a var for unwanted chars

Post by rufee »

JNettles wrote:Regex.
But its deprecated in 5.3.0
any solution to that ?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: checking a var for unwanted chars

Post by AbraCadaver »

rufee wrote:
JNettles wrote:Regex.
But its deprecated in 5.3.0
any solution to that ?
Regex, deprecated? That would be horrible. The ereg_* functions are deprecated so use preg_match() or preg_replace(), etc...
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: checking a var for unwanted chars

Post by requinix »

rufee wrote:such as " ' ` {}[]()<>/?|"
How about a list more specific than just "such as"? Maybe you want just letters and numbers?
Post Reply