dousha1873 2010-03-03 06:50
浏览 64
已采纳

PHP加速器和静态字段

I would like to know about static (class) field representation within PHP interpreter.

For example, when you load a class in Java, static fields will be associated with that Class object; that means two applications running same JVM (and same classloader) will have some kind of shared global variable ;)

I'm just wondering, if I use some kind of PHP accelerator/opcode caching, what is that really cached? Is it just compiled bytecode, or a piece of VM state (responsible for storing class objects)?

It's because I'm afraid of static fields/singleton objects sharing between requests, etc.

P.S.: I'm really a PHP newbie, so I'm very sorry if the question is way too dumb :)

  • 写回答

1条回答 默认 最新

  • douxie2029 2010-03-03 06:57
    关注

    An opcode cache will not change anything : each PHP script is executed by its own process (or thread), in isolation from the others.

    An opcode cache will only cache opcodes (the PHP equivalent of JAVA's bytecode), and will nor store not related to the current execution of the script -- i.e. not any kind of "VM state".

    This means your static variables will exist in one version for each execution of your PHP script, even if that script is executed several times in parallel ; and using or not an opcode cache will not change a thing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 35114 SVAC视频验签的问题
  • ¥15 impedancepy
  • ¥15 在虚拟机环境下完成以下,要求截图!
  • ¥15 求往届大挑得奖作品(ppt…)
  • ¥15 如何在vue.config.js中读取到public文件夹下window.APP_CONFIG.API_BASE_URL的值
  • ¥50 浦育平台scratch图形化编程
  • ¥20 求这个的原理图 只要原理图
  • ¥15 vue2项目中,如何配置环境,可以在打完包之后修改请求的服务器地址
  • ¥20 微信的店铺小程序如何修改背景图
  • ¥15 UE5.1局部变量对蓝图不可见