0

我遇到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

4 回答 4

3

来自文档

<?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.";
于 2012-12-07T00:42:47.597 回答
1

改用超全局$_SESSION

$_SESSION['username'] = $username;
于 2012-12-07T00:41:53.183 回答
1

在向浏览器输出任何内容之前,将其放在session_start();脚本/页面的最顶部,并将这些行替换为:

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
于 2012-12-07T00:42:57.740 回答
1

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

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

于 2012-12-07T00:43:18.543 回答