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 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么