PHP length of string

Getting the length of a string is done easily in PHP by using the strlen($string_variable) function.
Example
stringlen.php:

<html>
<head>
<title> Length of string</title>
</head>
<body>
<form action="stringlen.php" method="get">
<label for="pwd">Password:</label>
<input type="password" name="pwd">
<input type="submit" name="sm" value="Submit">
</form>
<?php
$p=$_GET['pwd'];
if(strlen($p)<8) echo "<p style='color: #ff0000'> Too short!</p>";
else echo "<p style='color: #0000ff'> Good!</p>";

?>
</body>
</html>

Posted by: Lavy | post date: 02-04-2013 | Subject: PHP




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.