Checking String Length : strlen « String « PHP






Checking String Length

 
<?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.
  }
?>
  
  








Related examples in the same category

1.Calculating the length of a string
2.Checking String Length: int strlen ( string string )
3.Concisely checking the length of a trimmed string
4.strlen.php
5.int strlen ( string str ) returns the number of characters in it: