请输入您要查询的百科知识:

 

词条 shmop
释义

简介

Shmop是一个易于使用的功能集,允许PHP读,写,创建和删除UNIX共享内存段。

安装

要使用shmop ,您将需要使用 - enable - shmop在配置行中的参数来编译PHP。

注意事项

到Windows 2000以前的Windows版本不支持共享内存。在Windows下, Shmop只会当PHP作为Web服务器模块运行,如Apache或IIS ( CLI和CGI将无法正常工作) 。

函数方法

shmop_close— 关闭共享内存块

shmop_delete— 删除共享内存块

shmop_open— 创建或打开共享内存块

shmop_read—从共享内存块读取数据

shmop_size— 获取共享内存块的大小

shmop_write— 到共享内存块写入数据

使用示例

<?php

// Create 100 byte shared memory block with system id of 0xff3

$shm_id = shmop_open(0xff3, "c", 0644, 100);

if (!$shm_id) {

echo "Couldn't create shared memory segment\";

}

// Get shared memory block's size

$shm_size = shmop_size($shm_id);

echo "SHM Block Size: " . $shm_size . " has been created.\";

// Lets write a test string into shared memory

$shm_bytes_written = shmop_write($shm_id, "my shared memory block", 0);

if ($shm_bytes_written != strlen("my shared memory block")) {

echo "Couldn't write the entire length of data\";

}

// Now lets read the string back

$my_string = shmop_read($shm_id, 0, $shm_size);

if (!$my_string) {

echo "Couldn't read from shared memory block\";

}

echo "The data inside shared memory was: " . $my_string . "\";

//Now lets delete the block and close the shared memory segment

if (!shmop_delete($shm_id)) {

echo "Couldn't mark shared memory block for deletion.";

}

shmop_close($shm_id);

?>

PHP语言介绍

PHP(PHP:Hypertext Preprocessor)是一种在电脑上运行的脚本语言,主要用途是在于处理动态网页,也包含了命令行运行接口(command line interface),或者产生图形用户界面(GUI)程序。PHP最早由Rasmus Lerdorf在1995年发明,而现在PHP的标准由PHP Group和开放源代码社区维护。PHP以PHP License作为许可协议,不过因为这个协议限制了PHP名称的使用,所以和开放源代码许可协议GPL不兼容。PHP的应用范围相当广泛,尤其是在网页程序的开发上。一般来说PHP大多运行在网页服务器上,通过运行PHP代码来产生用户浏览的网页。PHP可以在多数的服务器和操作系统上运行,而且使用PHP完全是免费的。

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2025/2/7 16:21:17