Home > Code Snippets > Limit the length of a text string being entered into a database
Limit the length of a text string being entered into a database
Description
This can be used if you want to limit a string, for example if you want to limit the length of user inputted text that is being saved to a database.
The code
<?php
if (strlen($text) > "255") {
exit("The text you entered is too long.");
}
?>
Get the code
Download the file to your computer: Click here to get the file
