<?php

for ($i = 0; $i < 30; $i++) wc();

function wc() 
{
  $datafile = "test.txt";

  if(!file_exists($datafile)) 
  {
    trigger_error("Couldn't find datafile $datafile.", E_USER_ERROR);
  }

  $fd = fopen($datafile, "rt");
  $nl = $nw = $nc = 0;
  while (!feof ($fd)) 
  {
    if ($line = fgets($fd)) 
    {
		  ++$nl;
      $nc += strlen($line);
    }
  }
  fclose($fd);
  print "$nl $nw $nc\n";
}

?>