In PHP one can use variable variables...
For example...
class obj { } $fieldName = \"Surname\"; $object = new obj(); $object->Name = \"John\"; $objec
As it was already replied, but not with a complete line of code:
if ( preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/','evaluation string') ) { // the string is valid } else { // the string is not valid }