
streamWrapper::stream_eof 메소드는 streamWrapper가 읽기 또는 쓰기 연산을 하기 전에 EOF 상태를 확인하는 메소드입니다. 이 메소드는 streamWrapper가 EOF 상태인지 아닌지를 확인하여, 읽기 또는 쓰기 연산을 수행하기 전에 EOF 상태인지 여부를 판단하는 데 사용됩니다.
streamWrapper::stream_eof 메소드는 streamWrapper가 현재 위치에 EOF 상태인지 확인합니다. 만약 현재 위치가 EOF 상태라면, 메소드는 TRUE를 반환합니다. 그렇지 않으면 FALSE를 반환합니다.
EOF 상태를 확인하는 예제를 살펴보겠습니다.
#hostingforum.kr
php
class MyStreamWrapper extends StreamWrapper {
private $eof;
public function stream_eof() {
return $this->eof;
}
public function stream_open($path, $mode) {
if ($mode == 'r') {
$this->eof = true;
} else {
$this->eof = false;
}
}
}
$wrapper = new MyStreamWrapper();
echo $wrapper->stream_eof() ? 'EOF' : 'Not EOF'; // Not EOF
$wrapper->stream_open('example.txt', 'r');
echo $wrapper->stream_eof() ? 'EOF' : 'Not EOF'; // EOF
위 예제에서, MyStreamWrapper 클래스는 streamWrapper::stream_eof 메소드를 오버라이딩하여 EOF 상태를 확인합니다. stream_open 메소드는 읽기 모드일 때 EOF 상태를 TRUE로 설정합니다. EOF 상태를 확인하기 위해 stream_eof 메소드를 호출하면, 현재 위치에 EOF 상태인지 여부를 확인할 수 있습니다.
2025-08-03 07:03