This is not the full PHP Syntax as Regex (which would not make much sense, use the tokenizer instead), but a collection of regular expressions for various elements of the PHP syntax I ran over lately.
While compiling this list it came to my attention that it is the same for Constant, Variable, Function and Class Names:
* Unknown so far. Must somehow contain
"\". But the same for class and function names, right? Probably the PHP Manual needs an update because of PHP 5.3.
Values, they are mostly quite easy, aren’t they? So I only pick those subjectively noteworthy for the moment.
||As specified in the PHP Manual for Integers|
||Float was named Double in the past. I needed to extend the expression from the Float Manual as it didn’t care about the INF part and some other details.|
If you’re dealing with the string representation of a PHP value in its serialized form, you need to differ. They do not strictly match with the regexes above. Those follow some similar but own rules. If you want to find out more, unserialize() is giving note if something did not work.
I probably will add some more if I need them and I run over them. Same probably for serialized values. You can leave suggestions in the comments as well.
Image Credits: Citations from Along the River During Qingming Festival, 18th century remake of a 12th century original by Chinese artist Zhang Zeduan; via Trialsanderrors