Sync SyncSharedMemory::write

(PECL sync >= 1.1.0)

SyncSharedMemory::write — 명명된 공유 메모리에 데이터 복사


설명

public SyncSharedMemory::write(string $string = ?, int $start = 0)

명명된 공유 메모리에 데이터를 복사합니다.


매개변수

string
공유 메모리에 쓸 데이터입니다.

메모: 데이터 크기가 공유 메모리 크기를 초과하는 경우 반환된 쓰기 바이트 수는 입력 길이보다 작습니다.

start
쓰기를 시작할 시작/오프셋(바이트)입니다.
메모:

값이 음수이면 시작 위치는 공유 메모리 세그먼트의 끝에서 지정된 바이트 수에서 시작됩니다.


반환 값

공유 메모리에 기록된 바이트 수를 포함하는 정수입니다.


Examples

예제 #1 SyncSharedMemory::write() 예제

                  
<?php
// You will probably need to protect shared memory with other synchronization objects.
// Shared memory goes away when the last reference to it disappears.
$mem = new SyncSharedMemory("AppReportName", 1024);
if ($mem->first())
{
    // Do first time initialization work here.
}

$result = $mem->write("report.txt");
var_dump($result);

$result = $mem->write("report.txt", -3);
var_dump($result);
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

int(10)
int(3)
                

기타