result.php
<html>
<meta charset="UTF-8">
<body>
<?php
$input = $_REQUEST["Input"];
$count = 0;
for ($i = 0; $i < $input; $i++)
{
$x = $input % 10;
if ($x % 2 == 0)
{
$count++;
}
$input = (int)($input / 10);
}
?>
Числото <?php echo $_POST["Input"]; ?> съдържа <?php echo $count ?> четни цифри.
</body>
</html>
Change to:
<html>
<meta charset="UTF-8">
<body>
<?php
$input = str_split($_REQUEST["Input"]);
$input_length = count($input);
$count = 0;
for($i = 0; $i < $input_length; ++$i){
if($input[$i] % 2 === 0){
++$count;
}
}
?>
Числото <?php echo $_POST["Input"]; ?> съдържа <?php echo $count ?> четни цифри.
</body>
</html>
7
solved Program that counts even digits in given number, but eats the first digit, and sometimes not. How to fix?