1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-26 00:32:15 +01:00
Files
archived-doc-ru/reference/shmop/examples.xml
Sergey Panteleev daef8df962 Обнуление тега Reviewed (#364)
[skip-lint]
[skip-spellcheck]
2021-11-16 13:03:53 +03:00

72 lines
2.5 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 79dcbe011fb254dcd92c597064571fe313362a09 Maintainer: aur Status: ready -->
<!-- Reviewed: no -->
<chapter xml:id="shmop.examples" xmlns="http://docbook.org/ns/docbook">
&reftitle.examples;
<section xml:id="shmop.examples-basic">
<title>Базовое использование</title>
<para>
<example>
<title>Обзор операций с разделяемой памятью</title>
<programlisting role="php">
<![CDATA[
<?php
// Создание блока с идентификатором 0xff3 и размером в 100 байт.
$shm_id = shmop_open(0xff3, "c", 0644, 100);
if (!$shm_id) {
echo "Невозможно зарезервировать блок в сегменте памяти\n";
}
// Получение размера блока в разделяемой памяти
$shm_size = shmop_size($shm_id);
echo "Участок памяти, размером: " . $shm_size . ", успешно зарезервирован.\n";
// Проверочная запись некоторой строки в разделяемую память
$shm_bytes_written = shmop_write($shm_id, "Мой маленький блок", 0);
if ($shm_bytes_written != strlen("Мой маленький блок")) {
echo "Не удалось записать весь размер данных\n";
}
// Получение хранимой строки из разделяемой памяти
$my_string = shmop_read($shm_id, 0, $shm_size);
if (!$my_string) {
echo "Невозможно прочитать данные из блока памяти\n";
}
echo "Данные, размещённые в разделяемой памяти: " . $my_string . "\n";
// Удаление блока и закрытие сегмента разделяемой памяти
if (!shmop_delete($shm_id)) {
echo "Невозможно отметить участок памяти для освобождения.";
}
shmop_close($shm_id);
?>
]]>
</programlisting>
</example>
</para>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->