phpbb 3.1在2页之间传递变量

时间:2016-02-09 14:39:23

标签: php phpbb3

使用phpbb3.1,它们似乎已经禁用了更多超级全局。 我尝试在使用会话之间传递变量,但没有成功。

$_SESSION['example'] = 'example';
$example = $_SESSION['example'];

由于phpbb禁用超级全局,因此没有任何内容存储。什么是在页面之间传递变量的下一个最佳和最安全的方法?

2 个答案:

答案 0 :(得分:1)

我不确定是否包含$_SESSION,但请尝试使用phpBB request类......

$example = $request->variable('example','');

课程的文档在这里 - https://wiki.phpbb.com/PhpBB3.1/RFC/Request_class

答案 1 :(得分:1)

您可能需要查看this answer,其中我解释说您还可以暂时(或全局)切换 Superglobals

<强>全球

打开/phpbb/config/parameters.yml文件,将 core.disable_super_globals 键从true更改为false

<强>编程

这是一个示例代码,可用于临时启用超全局( per-request 范围):

// temporarily enable superglobals
$request->enable_super_globals();

// TODO: do your stuff here.

// disable superglobals again
$request->disable_super_globals();

您还可以阅读我在此主题上撰写的this blog post以获取更多信息。