Showing posts with label Maximum String Length. Show all posts
Showing posts with label Maximum String Length. Show all posts

Sunday, 18 September 2016

PHP Validation Function for Maximum String Length

Useful PHP form validation function to validate the length of the string against the maximum allowed string length which in default has a maximum length of 10. Use this validation function to validate the string length of a string.

function validateMaxLength($allowed_length, $allowed_length=10) {
    return (strlen($allowed_length) <= (int)$allowed_length);
}

Friday, 9 September 2016

PHP Function to Validate String Length

Simple php function to validate the maximum length of a given string. Use this function to test if a given string's length is within the allowed limit. Validate maximum length of a string in php.

function validateMaxlength($string, $max_len) {
    return (strlen($string) <= (int)$max_len);
}