热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

shmop_open函数找不到,怎么办,刚装的PHP5

版本:php-5.2.0-Win32页面代码:<?php$wordsarray(aaa,bbb,ccc,ddd);申请共享内存空间$shm_idshmop
版本:php-5.2.0-Win32
页面代码:

$words=array('aaa','bbb','ccc','ddd');
//申请共享内存空间
$shm_id = shmop_open(0xff3, "c", 0644, 10485760);


//序列化
$value = serialize($words);

//写入共享内存空间
shmop_write($shm_id, $value, 0);

//获取共享内存空间中的内容
$my_string = shmop_read($shm_id, 0, strlen($value));
shmop_close($shm_id);
?>

错误信息:

Fatal error: Call to undefined function shmop_open() in D:\wwwroot\php5_test\index.php on line 4


php.ini中已经取消了php_shmop.dll前面的分号,并重启了windows2000

5 个解决方案

#1


shmop_open   
  (PHP   4   >=   4.0.4)   
    
  shmop_open   --   Create   or   open   shared   memory   block   
  Description   
  int   shmop_open   (   int   key,   string   flags,   int   mode,   int   size)   
    
    
  shmop_open()   can   create   or   open   a   shared   memory   block.     
    
  shmop_open()   takes   4   parameters:   key,   which   is   the   system's   id   for   the   shared   memory   block,   this   parameter   can   be   passed   as   a   decimal   or   hex.   The   second   parameter   are   the   flags   that   you   can   use:     
    
    
  "a"   for   access   (sets   SHM_RDONLY   for   shmat)   use   this   flag   when   you   need   to   open   an   existing   shared   memory   segment   for   read   only     
    
  "c"   for   create   (sets   IPC_CREATE)   use   this   flag   when   you   need   to   create   a   new   shared   memory   segment   or   if   a   segment   with   the   same   key   exists,   try   to   open   it   for   read   and   write     
    
  "w"   for   read   &   write   access   use   this   flag   when   you   need   to   read   and   write   to   a   shared   memory   segment,   use   this   flag   in   most   cases.     
    
  "n"   create   a   new   memory   segment   (sets   IPC_CREATE|IPC_EXCL)   use   this   flag   when   you   want   to   create   a   new   shared   memory   segment   but   if   one   already   exists   with   the   same   flag,   fail.   This   is   useful   for   security   purposes,   using   this   you   can   prevent   race   condition   exploits.     
    
  The   third   parameter   is   the   mode,   which   are   the   permissions   that   you   wish   to   assign   to   your   memory   segment,   those   are   the   same   as   permission   for   a   file.   Permissions   need   to   be   passed   in   octal   form   ex.   0644.   The   last   parameter   is   size   of   the   shared   memory   block   you   wish   to   create   in   bytes.     
  Note:   Note:   the   3rd   and   4th   should   be   entered   as   0   if   you   are   opening   an   existing   memory   segment.   On   success   shmop_open()   will   return   an   id   that   you   can   use   to   access   the   shared   memory   segment   you've   created.     
    
    
  Example   1.   Create   a   new   shared   memory   block   
    
    $shm_id   =   shmop_open(0x0fff,   "c",   0644,   100);   
  ?>   
      
      
    
    
  This   example   opened   a   shared   memory   block   with   a   system   id   of   0x0fff.     
    
  User   Contributed   Notes   
  shmop_open         
  macmaster@pobox.com   
  30-Mar-2001   12:15     
      
  the   key   is   a   LONG   variable   type,   meaning   that   the   key   can   only   be   eight   (8)   
  bytes   long,   which   can   be   too   short   if   you're   using   any   form   of   automagic   
  key   generation   (like   a   parsed   filename)   
    
      
      
  Mitchell_Shnier@ieee.orgZ   
  07-Nov-2001   05:51     
      
  To   check   whether   a   particular   shared   memory   segment   is   already   created,   you   
  need   to   concatenate   the   "a"   and   "c"   flags.   For   example   
  (where   $SystemKey   is   the   Unix   key   used   by   the   other   process(es)   with   which   
  you   want   to   share   this   memory   segment)...   
  $shm_id   =   shmop_open($SystemKey,   "ac",   0,   0);   
  if   ($shm_id)   {   
        #it   is   already   created   
  }   else   {   
        #you   need   to   create   it   with   shmop_open   using   "c"   only   
  }   
  Using   only   "a"   does   not   work   (just   as   using   only   IPC_EXCL   in   the   
  Unix   shmget()   call   is   meaningless).   Also,   use   the   ipcs   shell   command   to   
  see   your   shared   memory   segments.   
    
      
      
  hackie@prohost.org   
  20-Jan-2002   05:04     
      
  All   of   the   problems   have   been   addressed   in   the   CVS,   in   addition   the   a   mode   
  now   indeed   DOES   attach   to   the   segment   in   readonly   mode   (i.e.   SHM_RDONLY),   
  so   using   shm_write   on   it   would   fail   with   a   warning.   It   has   2   new   flags   w   
  (read/write)   and   n   (new   segment   IPC_CREAT|IPC_EXCL).     
  And   a   number   of   segfaults   fixed   :)   
  这是php.net提供的函数和一些网友使用心得   
    
  我的看法是   
    $shm_id=shmop_open("login","c",0644,2);----注意权限是0644也就是   
      6                     4                               4   
  写,执行       执行                       执行   
  而你在第二个页面用$login=shmop_read($shm_id1,0,1)来”读“所以提示说   
  unable   to   attach   or   create   shm   segment   on   line   2   
  浅妄薄见,望与斟酌   

#2


楼上的兄弟请看帖再回帖

#3


重新装

#4


重新装?我是手工安装的,说白了,就是直接把iis中的isapi加上

#5


重新装了个安装版的php5.2.4解决了

推荐阅读
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 本题探讨了一种字符串变换方法,旨在判断两个给定的字符串是否可以通过特定的字母替换和位置交换操作相互转换。核心在于找到这些变换中的不变量,从而确定转换的可能性。 ... [详细]
  • 技术分享:从动态网站提取站点密钥的解决方案
    本文探讨了如何从动态网站中提取站点密钥,特别是针对验证码(reCAPTCHA)的处理方法。通过结合Selenium和requests库,提供了详细的代码示例和优化建议。 ... [详细]
  • Java 中的 BigDecimal pow()方法,示例 ... [详细]
  • 本文介绍如何利用动态规划算法解决经典的0-1背包问题。通过具体实例和代码实现,详细解释了在给定容量的背包中选择若干物品以最大化总价值的过程。 ... [详细]
  • 本文介绍了Java并发库中的阻塞队列(BlockingQueue)及其典型应用场景。通过具体实例,展示了如何利用LinkedBlockingQueue实现线程间高效、安全的数据传递,并结合线程池和原子类优化性能。 ... [详细]
  • 深入理解Cookie与Session会话管理
    本文详细介绍了如何通过HTTP响应和请求处理浏览器的Cookie信息,以及如何创建、设置和管理Cookie。同时探讨了会话跟踪技术中的Session机制,解释其原理及应用场景。 ... [详细]
  • 主要用了2个类来实现的,话不多说,直接看运行结果,然后在奉上源代码1.Index.javaimportjava.awt.Color;im ... [详细]
  • 在前两篇文章中,我们探讨了 ControllerDescriptor 和 ActionDescriptor 这两个描述对象,分别对应控制器和操作方法。本文将基于 MVC3 源码进一步分析 ParameterDescriptor,即用于描述 Action 方法参数的对象,并详细介绍其工作原理。 ... [详细]
  • 本文详细介绍了Java编程语言中的核心概念和常见面试问题,包括集合类、数据结构、线程处理、Java虚拟机(JVM)、HTTP协议以及Git操作等方面的内容。通过深入分析每个主题,帮助读者更好地理解Java的关键特性和最佳实践。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
author-avatar
韩韩韩韩韩海
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有