-2
我有一個簡單的PHP腳本,不斷拋出這個古怪的錯誤消息:什麼原因導致意外的T_CONSTANT_ENCAPSED_STRING錯誤?
Parse error: syntax error, unexpected '"string' (T_CONSTANT_ENCAPSED_STRING) in /script.php
<?php
error_reporting(-1);
require_once "PHPMailer/PHPMailerAutoload.php";
$api_key = "string"; // this line causes the error
$payload = file_get_contents("php://input");
$new_booking = json_decode($payload, true);
$schedule_id = "123456";
$schedule_link = "http://example.com";
$passwd = "passwd";
// email config
$admin = [
"name" => "Joe White",
"user" => "[email protected]",
"passwd" => "passwd"
];
$max_time = 3; // hours
$max_dist = 200; // miles
/*
Code goes on, but is commented out and therefore not included here
*/
?>
我看到有人在另一提到的SO問題,這個問題可能是CRLF行結束,而不是CF,但我不確定。
錯誤消息告訴你這個錯誤是什麼行號? –
並且您是否顯示了該特定行的代碼? – RamRaider
停止在文件末尾使用關閉php標籤('?>')。他們根本沒有任何目的,並一直造成麻煩。 – arkascha