dongying7847 2013-07-11 07:31
浏览 74
已采纳

使用Zend Framework定义常量的位置

I have a few genuine constants that I would like to use in Zend Framework. I know I can set them in the index.php but this is not executed when running PHPUnit tests. (Not in this case, anyhow).

How else can I set these within the framework? The problem is that constants need to be declared outside the class. (I don't want class constants).

If all else fails, I can set them in my unit testing bootstrap, but I'd like to avoid the duplication if possible.

  • 写回答

3条回答 默认 最新

  • drq1257 2013-07-11 07:34
    关注

    I always define them in the bootstrap file. But i do use the Zend_Registry instead of constants.

    Zend_Registry::set('property1', 'value1');
    
    //everywhere in your code
    $value = Zend_Registry::get('property1');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器