As in HTML 4 specification noted that :
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (“-“), underscores (“_”), colons (“:”), and periods (“.”).
How can I validate an ID/NAME token is valid by using PHP?
I suppose a regular expression such as this one could do the trick :
For more informations, see the following section of the manual : Regular Expressions (Perl-Compatible)
And to use that, in PHP, you’d have to use the
preg_match()function :