PHP 致命错误:调用未定义的函数 session_register()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20661991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP Fatal error: Call to undefined function session_register()
提问by AndreiG.
I have moved my site from php 5.3 to 5.4 and now I cannot login to site admin
我已将我的网站从 php 5.3 移至 5.4,现在我无法登录到网站管理员
I see this error:
我看到这个错误:
PHP Fatal error: Call to undefined function session_register() in /home/regimhot/public_html/webmotionsV4/mvc/models/kit_model_useri.php on line 18
PHP 致命错误:在第 18 行调用 /home/regimhot/public_html/webmotionsV4/mvc/models/kit_model_useri.php 中未定义的函数 session_register()
The code with the problem is:
有问题的代码是:
function login($username, $password) {
if(!$username || !$password) return false;
if($this->useri[$username]['password']==$password) {
session_register('userInfo');
$_SESSION['userInfo'] = $this->useri[$username];
$_SESSION['userInfo']['logat'] = true;
$this->userInfo = &$_SESSION['userInfo'];
How can I solve the problem? i know that the function session_register is not suported by php 5.4
我该如何解决问题?我知道 php 5.4 不支持 session_register 函数
回答by Connor Tumbleson
This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
该函数自 PHP 5.3.0 起已弃用,自 PHP 5.4.0 起已移除。
http://www.php.net/manual/en/function.session-register.php
http://www.php.net/manual/en/function.session-register.php
Make sure you have session_start(), as just removing session_register()and relying on the $_SESSIONassignment won't work.
确保你有session_start(),因为仅仅删除session_register()和依赖$_SESSION分配是行不通的。
回答by Julio
Per the documentation, the session_register()function was deprecated in version 5.3.0 and removed from PHP entirely in 5.4.0. I suspect that you're using version 5.4.0.
根据文档,该session_register()函数在 5.3.0 版中已弃用,并在 5.4.0 版中完全从 PHP 中删除。我怀疑您使用的是 5.4.0 版。

