Php ile dosya açmak için fopen komutu kullanılır. Bu komut ile birlikte kullılan parametreye göre dosya okuma yada yazma işlemi yapılır.

w: dosyaya yazma
r: dosyadan okuma
a: dosyaya ekleme

$file = fopen("metin.txt", "r") OR exit("Dosya hatası");
while(!feof($file))
{
$satir=fgets($file);
$satir;
}
fclose($file);


Burada kullanılan fgets komutu dosyadaki her satırı tek tek okumaya yarar.