我有一个简单的PHP脚本,不断抛出这个奇怪的错误信息:
解析错误:语法错误,意外'""字符串' /script.php中的(T_CONSTANT_ENCAPSED_STRING)
<?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" => "user@gmail.com",
"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,但我不确定。
答案 0 :(得分:0)
好吧,我最终找到了一个解决方案,错误是由于一些损坏的空格/换行符,并且因为我不想浏览整个文件,所以我使用了这些工具:
http://www.textfixer.com/tools/remove-line-breaks.php http://www.textfixer.com/tools/remove-white-spaces.php
这是验证代码: http://phpcodechecker.com
这样可以再次美化代码: http://www.cleancss.com/php-beautify/
请确保在此过程之前删除所有单行注释。