Count Words Without Using Function In Php

We can easily write a code that count words in a string with the help of any function. But how we can do this task without using function. Here is the code below to make this task done.

<?php ini_set('display_errors', 0);
error_reporting(E_ERROR | E_WARNING | E_PARSE);  ?>
<form action="" method="post">
Enter : <input type="text" name="txt" />
<input type="submit" name="sbt" />
</form>
<?php 
if (isset($_POST['txt']))
{
$string = $_POST['txt'];
$word = "";
$a = strlen($string);
$b = 0;
				while($b<=$a){
					$b++;
					if (ord($string[$b]) == 32 ){
					 $word = 	$word + 1;
						}
					}
					echo $word+1;
}
?>