我正在从事一个项目,将只使用SMF会员系统。这意味着SMF是我唯一用来登录的成员系统,而不是我自己的系统以及SMF,只是普通的SMF。然而,我遇到了一个问题...我需要能够从SMF获得信息的基础上给定的ID_MEMBER。我的文章数据库使用SMF的ID_MEMBER字段作为作者信息。看到CodeIgniter是MVC并使用类,我在互联网上搜索了一个通用的SMF类,但没有找到。我决定写我自己的,但不能让它正常工作…我对OOP没有太多的经验。
<?php
class smf {
var $context;
var $memberContext;
function __construct($who){
include('/../../forums/SSI.php');
$this->context = $context;
}
function user_context(){
return $this->context['user'];
}
function member_context($id = NULL){
loadMemberData($id);
loadMemberContext($id);
return $memberContext[$id];
}}
user_context函数运行正常,但member_context函数运行不正常。在SSI.php文件中,LoadmemberContext函数将所有信息编译到一个名为$memberContext$id的数组中。当我从我的CodeIgniter控制器调用这个方法时,我得到一个错误,说$memberContext变量是未定义的。为什么会发生这种情况?
发布于 2012-12-11 23:17:22
我也偶然发现了这个问题,并设法解决了它。试试这个,它对我很有效:
function member_context($id = NULL) {
loadMemberData($id);
loadMemberContext($id);
global $user_profile;
return $user_profile[$id];
}https://stackoverflow.com/questions/12558570
复制相似问题