$file = "veri.txt";
$satirSayisi = getLines($file);

$satir = rand(0,$satirSayisi);
$i = 0;
$handle = fopen($file, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if($satir === $i){
echo $line;
}
$i++;
}

fclose($handle);
} else {
// error opening the file.
}

function getLines($file)
{
$f = fopen($file, 'rb');
$lines = 0;

while (!feof($f)) {
$lines += substr_count(fread($f, 8192), "\n");
}

fclose($f);

return $lines;
}
?>