It is in fact documented; what I didn't explain is that ctype_digit treats integers < 127 as chr() equivalents. It's designed to juggle both strings and integers, which indeed works against php's usual method of type juggling. This is because ctype is a port or wrapper around the C lib which behaves as such.
That is hilarious! I love how even stuff that is supposed to fix other stuff itself end up being completely broken. But hey, it is documented.
Learning Php is like taking a massive loan. It get you started easily, but causes eternal suffering in the long run...