5

Your code is really good, but there's a few things you could improve:
$errno, $errstr, it's silly to sacrifice readability for a few extra characters:
$errorNumber & $errorString is much better.
Instead of while (1), you should use while (true)
You should avoid directly adding words/n i...