会话故障 - 继续获取“无法在写入上下文中使用函数返回值”
问题描述:
I have seen several other threads with this error and none seem to solve my issue - I am thinking it's something out of the ordinary. My server is using PHP 5.4.20
The error I am getting is: Can't use function return value in write context in /home1/tradeinc/public_html/checklogin.php on line 4
Here is the snippet of code I have isolated the problem down to - I removed literally everything from the file except the following lines and the error persists.
<?php
session_start();
$username = "test";
$_SESSION('username') = $username;
?>
答
You have to access $_SESSION
as an array with []
not as a function with ()
.
$_SESSION['username']