- fclose: documentation ( source)
- feof: documentation ( source)
- fgets: documentation ( source)
- fopen: documentation ( source)
<?php
/**
* For this test someone has written a lot of crap PHP code!
* List all the problems you can find with this code and why it is a problem
*
*/
function countVowelsInFile($f)
{
$handle = fopen($f);
while (!feof($handle)) $buf = fgets($handle, 4096);
for ($i = 0; $i < strlen($buf); $i++)
{
if ($buf[$i] == 'a') $a++;
if ($buf[$i] == 'e') $e++;
if ($buf[$i] == 'i') $i++;
if ($buf[$i] == 'o') $o++;
if ($buf[$i] == 'u') $u++;
if ($buf[$i] == 'e') $e++;
}
fclose($handle);
return $a + $e + $i + $o + $u;
}
countVowelsInFile(__FILE__);