处理php中已弃用的错误

时间:2012-12-07 00:41:01

标签: php

如何解决我遇到的errors中的php

Deprecated: Function session_register() is deprecated in C:\xampp\htdocs\mysite\forum part two\login.php on line 62

Deprecated: Function session_register() is deprecated in C:\xampp\htdocs\mysite\forum part two\login.php on line 63

第62行和第63行的代码分别如下所示

session_register("username", $username);
session_register("password", $password); 

提前致谢

4 个答案:

答案 0 :(得分:3)

来自docs

<?php
// Use of session_register() is deprecated
$barney = "A big purple dinosaur.";
session_register("barney");

// Use of $_SESSION is preferred, as of PHP 4.1.0
$_SESSION["zim"] = "An invader from another planet.";

答案 1 :(得分:1)

请改用超级全球$_SESSION

$_SESSION['username'] = $username;

答案 2 :(得分:1)

在将任何内容输出到浏览器并将行替换为:

之前,将session_start();放在脚本/页面的最顶部
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

答案 3 :(得分:1)

$_SESSION['username'] = &$username;

为了复制您需要存储变量引用的功能。