Home  >  Article  >  Backend Development  >  这样找代码的思路对吗?

这样找代码的思路对吗?

WBOY
WBOYOriginal
2016-06-23 13:48:56905browse

下面这句话出自discuz程序,应该怎么理解呢?
$recommendgroups = array();
if($_G['forum']['status'] != 3 && helper_access::check_module('group')) {
loadcache('forumrecommend');
$recommendgroups = $_G['cache']['forumrecommend'][$_G['fid']];
}

if($recommendgroups) {
if(empty($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], 'recommendgroups_'.$_G['fid']) === FALSE) {
$collapse['recommendgroups'] = '';
$collapseimg['recommendgroups'] = 'collapsed_no.gif';
} else {
$collapse['recommendgroups'] = 'display: none';
$collapseimg['recommendgroups'] = 'collapsed_yes.gif';
}
}

我的难点是不理解这个二维数组是怎么来的$_G['forum']['status']


回复讨论(解决方案)

html页面有一个loop循环
显然这个 html 是模板了,因为 php 和 js 都没有 loop 循环
不过常见的模板引擎似乎也没有 loop 循环
你还是贴出标记吧

$_G['cache']['forumrecommend'][$_G['fid']]
我主要是不理解这个多维数组,它是啥意思呢

找到根目录下,forum.php
里面有个方法,loadforum();
该方法在/source/function/function_forum.php
方法中的:$forum = C::t('forum_forum')->fetch_info_by_fid($fid);,就是获取板块的设置
方法中有:$_G['forum'] = &$forum;,所以$_G['forum']['status']有值

loadcache('forumrecommend');
在pre_common_syscache中找到cname等于forumrecommend的缓存数据(二进制数据),放入$_G['cache']中
$_G['cache']['forumrecommend']是版主推荐的信息,对应的表pre_forum_forumrecommend 版主推荐表
$_G['fid']就是当前的板块id

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn