Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

shmop_read

Description

The shmop_read of Shmop for PHP reads data from the shared memory block.

Syntax

shmop_read(
    Shmop $shmop,
    int $offset,
    int $size
): string

Parameters

shmop

The shared memory block identifier created by shmop_open().

offset

Offset from which to start reading; must be greater than or equal to zero and less than or equal to the actual size of the shared memory segment.

size

The number of bytes to read; must be greater than or equal to zero, and the sum of offset and size must be less than or equal to the actual size of the shared memory segment.

0 = shmop_size($shmop) - $offset

Return

Returns the data on success or false on failure.

Examples

1 · shmop offset · 0 · size · 0

<?

$filename = __FILE__;
$project_id = "t";

$key = ftok($filename, $project_id);
$mode = "a";
$permissions = 0o644;
$size = 16;

$shmop = shmop_open($key, $mode, $permissions, $size);
$offset = 0;
$size = 0;

$return = shmop_read($shmop, $offset, $size);

var_dump($return);

?>
string(16) "mydata"

2 · shmop offset · 0 · size · 16

<?

$filename = __FILE__;
$project_id = "t";

$key = ftok($filename, $project_id);
$mode = "a";
$permissions = 0o644;
$size = 16;

$shmop = shmop_open($key, $mode, $permissions, $size);
$offset = 0;
$size = 16;

$return = shmop_read($shmop, $offset, $size);

var_dump($return);

?>
true

3 · shmop offset · 10 · size · 0

<?

$filename = __FILE__;
$project_id = "t";

$key = ftok($filename, $project_id);
$mode = "a";
$permissions = 0o644;
$size = 16;

$shmop = shmop_open($key, $mode, $permissions, $size);
$offset = 10;
$size = 0;

$return = shmop_read($shmop, $offset, $size);

var_dump($return);

?>
true

4 · shmop offset · 10 · size · 6

<?

$filename = __FILE__;
$project_id = "t";

$key = ftok($filename, $project_id);
$mode = "a";
$permissions = 0o644;
$size = 16;

$shmop = shmop_open($key, $mode, $permissions, $size);
$offset = 10;
$size = 6;

$return = shmop_read($shmop, $offset, $size);

var_dump($return);

?>
RIFFLWEBPVP8 @��*dd>m6�I�$�� ��
�in�s�ck���^X���E�k���^X����`
HomeMenu