我正在構建一些phpBB代碼的小包裝(這些方法將從項目的各個部分調用)。包含一個方法:一個限制範圍的修復?
問題是:由於http://php.net/manual/en/language.variables.scope.php,我包含在我的包裝內的所有東西都只有該方法範圍。
這裏簡化和相關部分:
public function usePhpBBUsers($phpbb_root_path)
{
include($phpbb_root_path . 'common.php');
include($phpbb_root_path . 'includes/functions_user.php');
$user->session_begin();
$auth->acl($user->data);
$user->setup();
}
我可以解決方法與global
變量範圍,但這些包括導入函數定義了。
想法?
您是否嘗試過使用關鍵詞'global'? – Ibu
@Ibu你讀過這個問題嗎? – deceze