以下脚本适用于 windows xampp, php 5.3.8
session_start();
if (empty($_SESSION['myvar']) && empty($_GET['myvar'])) {
$myvar = "some_value";
} elseif (!empty($_GET['myvar'])) {
$_SESSION['myvar'] = $_GET['myvar'];
}
$_SESSION['myvar'] = $myvar;
但在 ubuntu 服务器上,如果我var_dump($myvar)
的值为php 5.3.10null