Is there a way to check if a variable contains symbols? And then if it does produce an error?
example:
chee'se or ch{}#eese = error
but cheese would be ok.
Check characters of a variable
Moderator: General Moderators
Check characters of a variable
Last edited by SirChick on Thu Oct 25, 2007 6:13 pm, edited 1 time in total.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Solution would be regular expressions. Precise details not easily given as which characters are allowed a-z, 0-9, öäü ? If using UTF-8 you may also want to look at Multibyte String Functions
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
At this point, I can only recommend ctype_alnum().
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany