会话寄存器因弃用而无法正常工作

Reh*_*hmy 0 php

我有2个文件[a.php和b.php]

a.php代码

<?PHP
$msg= "Hello world";
session_register('msg');
header("Location: b.php ");
exit;
?>
Run Code Online (Sandbox Code Playgroud)

和b.php代码

<?PHP echo  $msg ; session_unregister('msg')?>
Run Code Online (Sandbox Code Playgroud)

php手册说" This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged."

所以我可以做任何改变,以便它再次工作?

Emi*_*röm 6

a.php只会

<?php
session_start();
$_SESSION['msg'] = 'Hello world';
header("Location: b.php ");
exit;
?>
Run Code Online (Sandbox Code Playgroud)

b.php

<?php
session_start();
echo $_SESSION['msg'];
unset($_SESSION['msg']);
?>
Run Code Online (Sandbox Code Playgroud)