라이브러리
[PHP] EventBufferEvent::getInput - 현재 버퍼 이벤트와 관련된 기본 입력 버퍼를 반환합니다.
EventBufferEvent::getInput
EventBufferEvent::getInput은 EventBufferEvent 객체에서 입력 버퍼를 가져오는 메서드입니다. 이 메서드는 EventBufferEvent 객체가 생성될 때 함께 생성된 버퍼를 반환합니다.
사용법
EventBufferEvent::getInput을 사용하려면 먼저 EventBufferEvent 객체를 생성해야 합니다. EventBufferEvent 객체는 EventBase 객체를 통해 생성됩니다.
#hostingforum.kr
php
use libeventEventBase;
use libeventEventBufferEvent;
// EventBase 객체 생성
$base = new EventBase();
// EventBufferEvent 객체 생성
$event = new EventBufferEvent($base, null, EventBufferEvent::READ);
// 입력 버퍼 가져오기
$input = $event->getInput();
예제
다음 예제는 EventBufferEvent::getInput을 사용하여 입력 버퍼를 가져오는 방법을 보여줍니다.
#hostingforum.kr
php
use libeventEventBase;
use libeventEventBufferEvent;
// EventBase 객체 생성
$base = new EventBase();
// EventBufferEvent 객체 생성
$event = new EventBufferEvent($base, null, EventBufferEvent::READ);
// 입력 버퍼 가져오기
$input = $event->getInput();
// 버퍼를 읽어들이는 함수
function readBuffer($input) {
$data = '';
while (true) {
$chunk = $input->read(1024);
if ($chunk === false) {
break;
}
$data .= $chunk;
}
return $data;
}
// 버퍼를 읽어들이기
$data = readBuffer($input);
// 버퍼 내용 출력
echo $data . "
";
// EventBase 객체 종료
$base->dispatch();
$base->stop();
$base->free();
참고
EventBufferEvent::getInput은 EventBufferEvent 객체가 생성될 때 함께 생성된 버퍼를 반환합니다. 이 버퍼는 EventBufferEvent 객체가 생성된 후에만 사용할 수 있습니다. 버퍼를 사용한 후에는 EventBufferEvent::getInput을 다시 호출하여 버퍼를 초기화해야 합니다.
EventBufferEvent::getInput을 사용하여 입력 버퍼를 가져올 때는 주의해야 합니다. 버퍼는 EventBufferEvent 객체가 생성된 후에만 사용할 수 있기 때문에, 버퍼를 사용한 후에는 EventBufferEvent::getInput을 다시 호출하여 버퍼를 초기화해야 합니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.