+1 vote
in Computer by kratos

Following is the code to count total number of characters from a text file. Fill in the blanks so that this code can work:

<? php

$file = ___(“data.txt”, “r”);

$ch = 0;

while(___($file))

{

$letter= ____;

$ch = ____;

}

echo “Number of characters:”, $ch;

fclose($file);

?>

1 Answer

+6 votes
by kratos
 
Best answer

<? Php

$file = fopen(“data.txt”, “r”);

$ch = 0;

while(!feof($file))

{

$letter=fgetc($file);

$ch=$ch+1;

}

echo “Number of characters:”, $ch;

fclose($file);

?>

...