$string = "Hello World"; $length = strlen($string); echo "The length of the string is: " . $length;
if(isset($_POST['submit'])) { $input = $_POST['input']; if(strlen($input) > 10) { echo "The input string is too long"; } else { echo "The input string is within the allowed limit"; } }In this example, the function is used to check the length of the input value from a form. If the length is greater than 10, it prints a message saying that the string is too long. Otherwise, it prints a message saying that the string is within the allowed limit. Package/Library: The strlen function is a built-in function in PHP and does not require any package or library to be imported.