热门标签 | 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解决了

推荐阅读
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • 本文介绍了Redis的基础数据结构string的应用场景,并以面试的形式进行问答讲解,帮助读者更好地理解和应用Redis。同时,描述了一位面试者的心理状态和面试官的行为。 ... [详细]
  • 如何用JNI技术调用Java接口以及提高Java性能的详解
    本文介绍了如何使用JNI技术调用Java接口,并详细解析了如何通过JNI技术提高Java的性能。同时还讨论了JNI调用Java的private方法、Java开发中使用JNI技术的情况以及使用Java的JNI技术调用C++时的运行效率问题。文章还介绍了JNIEnv类型的使用方法,包括创建Java对象、调用Java对象的方法、获取Java对象的属性等操作。 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文讨论了如何优化解决hdu 1003 java题目的动态规划方法,通过分析加法规则和最大和的性质,提出了一种优化的思路。具体方法是,当从1加到n为负时,即sum(1,n)sum(n,s),可以继续加法计算。同时,还考虑了两种特殊情况:都是负数的情况和有0的情况。最后,通过使用Scanner类来获取输入数据。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • C# 7.0 新特性:基于Tuple的“多”返回值方法
    本文介绍了C# 7.0中基于Tuple的“多”返回值方法的使用。通过对C# 6.0及更早版本的做法进行回顾,提出了问题:如何使一个方法可返回多个返回值。然后详细介绍了C# 7.0中使用Tuple的写法,并给出了示例代码。最后,总结了该新特性的优点。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • 本文介绍了Windows操作系统的版本及其特点,包括Windows 7系统的6个版本:Starter、Home Basic、Home Premium、Professional、Enterprise、Ultimate。Windows操作系统是微软公司研发的一套操作系统,具有人机操作性优异、支持的应用软件较多、对硬件支持良好等优点。Windows 7 Starter是功能最少的版本,缺乏Aero特效功能,没有64位支持,最初设计不能同时运行三个以上应用程序。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 阿,里,云,物,联网,net,core,客户端,czgl,aliiotclient, ... [详细]
  • 本文介绍了如何在给定的有序字符序列中插入新字符,并保持序列的有序性。通过示例代码演示了插入过程,以及插入后的字符序列。 ... [详细]
  • 本文讨论了clone的fork与pthread_create创建线程的不同之处。进程是一个指令执行流及其执行环境,其执行环境是一个系统资源的集合。在调用系统调用fork创建一个进程时,子进程只是完全复制父进程的资源,这样得到的子进程独立于父进程,具有良好的并发性。但是二者之间的通讯需要通过专门的通讯机制,另外通过fork创建子进程系统开销很大。因此,在某些情况下,使用clone或pthread_create创建线程可能更加高效。 ... [详细]
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社区 版权所有