171. PHP Program to find the length of the given string.
How does this program work?
- This program is used to find length of the given string using PHP.
Here is the code
<html>
<head>
<title>PHP Program To find length of the given string</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter String"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
function length($str)
{
$length = strlen($str);
//to count string length
return $length;
}
if(isset($_POST['submit'])) {
$s = $_POST['num1'];
echo "Given string : ".$s."</br>";
echo "Length of given String is : ".length($s);
return 0;
}
?>
</body>
</html>