dongmei9203 2013-09-28 21:40
浏览 36

静态类和全局变量

I'm using FuelPHP 1.6.1 with a lot of static classes, this seems to work out quite nice. Now I have a Menu generator that loads some data

$menu = Menu::generate();

It loads some data and stores this in static::$data How would I go for another class to load just that? I'm getting null results, probably because I'm doing something wrong, but I dont see what I'm doing wrong at the moment.

Also, yes, the Menu::$data is declared public static $data

Any tips?

Using FuelPHP's Session::set() does the job, but only after a reload, I need the data straight away in other classes, and loading it again results into double queries (which I dont want) PHP's $_SESSION is not used, nor will be used.

  • 写回答

1条回答 默认 最新

  • doukao5073 2013-09-28 21:48
    关注

    Turns out, in my way of showing views and menu, menu::generate() came after the other classes that needed it, put it at the start and using FuelPHP's Session::set() did the job

    评论

报告相同问题?

悬赏问题

  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗