新闻资讯
看你所看,想你所想

shmop

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

  • 外文名 shmop
  • 平台 Windows 2000
  • close 关闭共享内存块shm
  • delete 删除共享内存块

安装

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

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

函数

  ftok - 创建键 $shmop_key = ftok(__FILE__,'p');

  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 = shmo交丰p_open(0xff3, "c", 0644, 100);

  if (!$shm_i因理企晶差d) {

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

  }

  // Get shared memory block's size

  $shm_size = shmop_size($shm_id);

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

  // Lets write a test string into shared memory

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

  if ($shm_bytes_w仅振ritten != strlen("my shared memory block")) {

  e来自cho "Couldn't write the entire length of data\n";

  }

  // Now lets read the string back

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

  if (!$my_string) {

  echo "Couldn't read from sh独副买居脸硫必套保ared memory block\n";

  }

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

  //Now lets de360百科lete the block and close the shared memory segment

  if (!shmop_delete($shm_id)) {

  echo "Couldn't mark shared memory b事富铁推放低车lock for deletion.";

  }

  shmo移叫互鸡技货花编括p_close($shm_id);

  ?>

转载请注明出处安可林文章网 » shmop

相关推荐

    声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:fendou3451@163.com