[lang-ref] ( read_file_line_one_by_one ) ( php )

<?php
public function testReadFileLineOneByOne(): void
{
	// while (($line = fgets($fp)) !== false)
	$lines = ['test', 'test', 'test'];
	$text = implode("\n", $lines);
	$p = $this->tmpDir . DIRECTORY_SEPARATOR . 'a.txt';

	file_put_contents($p, $text);

	$fp = fopen($p, 'r');
	$this->assertNotFalse($fp);

	$linesNew = [];

	while (($line = fgets($fp)) !== false) {
		$linesNew[] = rtrim($line, "\r\n");
	}

	fclose($fp);

	$this->assertSame($lines, $linesNew);
}