Syntax error, unexpected T_SL

梦想与她 提交于 2019-12-04 03:01:21

Have a look at the List of Parser tokens.

T_SL references to <<.

You should not use tabs or spaces before you use END;. Have a look at this huge warning.

Just had the same problem.

Turned out to be content on the same line as my opening HERDEOC

wrong example

echo <<<HEREDOC code started on this line
HEREDOC;

correct example

echo <<<HEREDOC
code should have started on this line
HEREDOC;

Hope this helps someone else!

A side note, but might well help someone: a bad git merge can cause this. Consider:

function foo
    <<<<<<< HEAD
    $bar = 1;
    <<<<<<<  e0f2213bc34d43ef
    $bar = 2;

The PHP parser would produce the same error.

Source: just got bit by this ;)

What version of php are you using? The nowdoc syntax is only valid since PHP 5.3.0. See the manual: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc

There is a bug in function_mime_mailer.php:

if(empty($headers)){
   $headers = "MIME-Version: 1.0\n";
}else{
   $headers.= "\nMIME-Version: 1.0\n";
}

should be

if(empty($headers)){
   $headers = "MIME-Version: 1.0\r\n";
}else{
   $headers.= "\r\nMIME-Version: 1.0\r\n";
}

also, if you include the MIME-Version header, then the function will include it once more - effectively having two of them.

It had the same exact same issue but mine was because I had whitespace at the end of my heredoc on the top line:

$var = <<< HTML(whitespaces here caused the error)
stuff in here

HTML;

Source: http://realtechtalk.com/_syntax_error_unexpected_T_SL_in_PHP_Solution-2109-articles

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!