意外' $ _ SESSION'的语法错误

时间:2017-07-10 08:14:29

标签: php session

我正在尝试创建发布应用但找到了

  

解析错误:语法错误,意外' $ _会话' (T_VARIABLE)第5行

以下是第5行给出Parse错误的代码部分:



<?php

require "init.php"

$_SESSION["post"] = $_POST["data"];
$_SESSION["privacy"] = $_POST["privacy"];


//transfering to linkedin for authorization
header("location:",
"https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=".CLIENTID."&redirect_uri=".REDIRECTURI."&state=".CSRF."&scope=".SCOPES);


?>
&#13;
&#13;
&#13;

请看看它并指导我做了什么错误。 感谢

2 个答案:

答案 0 :(得分:1)

你错过了';'在第3行

<?php

require "init.php";
//                ^ notice this is missed in your code

答案 1 :(得分:0)

在代码开头使用session_start();

<?php
session_start();
require "init.php"

$_SESSION["post"] = $_POST["data"];
$_SESSION["privacy"] = $_POST["privacy"];


//transfering to linkedin for authorization
header("location:",
"https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=".CLIENTID."&redirect_uri=".REDIRECTURI."&state=".CSRF."&scope=".SCOPES);


?>