string-or-false * Return an error-message, if $str longer than $maxAllowedLen * or if $str contains spaces and $spacesAllowed===false. * Returns false, if there is no error-message to report. */ function stringInvalidMsg( $str, $maxAllowedLen, $spacesAllowed = true ) { $problemsSoFar = ""; $excessLen = (strlen($str) - $maxAllowedLen); if ($excessLen > 0) { $problemsSoFar .= "Can't be more than $maxAllowedLen characters long (is $excessLen characters too long).\n"; } if (!$spacesAllowed && preg_match('/\p{Z}/',$str)) { $problemsSoFar .= "Cannot contain any space characters.\n"; } return ($problemsSoFar==="") ? false : $problemsSoFar; } /* Test cases for above function: // a result of false means that there's no message about being invalid. test( stringInvalidMsg("", 0, true), false ); test( stringInvalidMsg("", 0, false), false ); test( stringInvalidMsg("", 99, true), false ); test( stringInvalidMsg("", 99, false), false ); test( stringInvalidMsg("abcdef", 99, true), false ); test( stringInvalidMsg("abcdef", 99, false), false ); test( stringInvalidMsg("abc def", 99, true), false ); // To test that the result is a string (but not caring/testing much about the string itself), // we'll just check that is_string(stringInvalidMsg(...)) is true. test( is_string(stringInvalidMsg("a", 0, false)), true ); test( is_string(stringInvalidMsg("a", 0, true)), true ); test( is_string(stringInvalidMsg(" ", 0, true)), true ); test( is_string(stringInvalidMsg("abc def", 99, false)), true ); test( is_string(stringInvalidMsg("abc def", 3, true)), true ); test( is_string(stringInvalidMsg("abc def", 3, false)), true ); */ $title = "Form Results"; ?>
It must be tough, to seek . Oh hey, what a coincidence; I love too.
I got the message, and the message is clear:
'> think you are happy.", "\n"; } else { echo " It is odd that you are happy, and you don't even know it.", "\n"; } ?>
The array _POST
=