This function has problems with string quoted with single quotes.
This code proves that
<?php
$ch = chr('%0A\\\');
$strings = array(\\\'string1\\\' => \\\'asdf\\\\n\\\\r\\\\t\\\', \\\'string2\\\' => $ch);
foreach ($strings as $name => $testcase) {
if (ctype_print($testcase)) {
echo \\\"The string \\\'$name\\\' consists of all printable characters.\\\\n\\\";
} else {
echo \\\"The string \\\'$name\\\' does not consist of all printable characters.\\\\n\\\";
}
}
?>
returns
The string \\\'string1\\\' consists of all printable characters.
The string \\\'string2\\\' does not consist of all printable characters.
So always quote your strings with double quotes.