Jump to: navigation, search

Php strlen

From w3cyberlearnings

Contents

PHP function strlen

This function returns the length of a given string.

Syntax strlen

  • string: string input.
strlen(string);

Example 1

<?php

echo strlen("Hello");
?>

Output

5

Example 2

<?php

$name = $_POST['name'] = 'Bob Maat Jing fd';

if (strlen($name) > 15) {
	echo 'User name is too long, please try again';
} else {
	echo 'User name is correct!';
}
?>

Output

User name is too long, please try again

Related Functions


Navigation
Web
SQL
MISC
References