PHP Checking String Length – String Function

<?php  define ("MAXLENGTH", 10);
  if (strlen ("Hello World!") > MAXLENGTH){
    echo "The field you have entered can only be " . MAXLENGTH . " characters in length.";
  } else {
    //Insert the field into the database.
  }
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.