How to set a global variable accessible throughout the application

前端 未结 7 1674
失恋的感觉
失恋的感觉 2021-01-13 04:20

I developed a PHP page with global variable like this;

global $amty_imgCache; $amty_imgCache = array();
$GLOBALS[\"amty_imgCache\"]=$amty_imgCache;


        
相关标签:
7条回答
  • 2021-01-13 05:18

    While I think most answers here are appropriate, I don't find them complete enough. PHP certainly has application-wide persistence only that you'd have to build such variables into PHP itself or a module that is loaded when PHP is first loaded by your web server. That means extending and rebuilding PHP itself or at least building and loading an external module.

    0 讨论(0)
提交回复
热议问题