php未定义变量:_session_register问题

时间:2013-02-12 04:47:35

标签: php session-variables

fully core php中创建了一个php项目。现在我的工作是改变一些风格问题。所以我只是用数据库下载了所有文件。我刚刚在localhost(LAMP)上配置了所有数据库名称,用户名和密码。当我浏览页面时,它显示的是页面,但是有一些错误。它显示错误,如

Notice: Undefined variable: _session_register in path to the folder/session.php on line 8 
Notice: Undefined variable: _session_register in path to the folder/session.php on line 9
Notice: Undefined variable: _session_register in path to the folder/session.php on line 10 
Notice: Undefined variable: _session_register in path to the folder/session.php on line 11 
Notice: Undefined variable: _session_register in path to the folder/session.php on line 12 
Notice: Undefined variable: _session_register in path to the folder/session.php on line 13

session.php的代码就像这样

<?php
$_SESSION['example']="yes"; 
ini_set("url_rewriter.tags","");
ini_set('session.use_trans_sid', 0);
ini_set("session.cookie_domain", ".localhost");
session_start();
ob_start();
$_session_register["easb2b_username"];
$_session_register["easb2b_userid"];
$_session_register["easb2b_memtype"];
$_session_register["easb2b_adv_id"];
$_session_register["easb2b_adv_email"];
$_session_register["lang"];
?>

有人可以告诉我如何解决这个问题。该项目有大约数千个文件。所以很难通过所有文件并检查它们。任何帮助和建议都会非常明显。感谢....

1 个答案:

答案 0 :(得分:0)

<?php
// Use of session_register() is deprecated
$new_sessionvar = "Some value.";
session_register("new_sessionvar");

但你仍然可以使用

session_start();
$_SESSION['new_sessionvar'] = "Some value"

要使用它,您需要在register_global

中启用php.ini

请注意,我在初始化之上有session_start()函数。在您的代码中,您可能希望将其添加到脚本的顶部以阻止Headers already sent by PHP message