解析错误:语法错误,第23行意外的T_SL

时间:2022-10-20 22:42:25

I am getting this error:

我收到此错误:

Parse error: syntax error, unexpected T_SL on line 23

解析错误:语法错误,第23行意外的T_SL

Here is line 23:

这是第23行:

$selectorder = <<<ORDER 

Here it is in context:

这是在上下文中:

$grid->setUrl('myfirstgrid.php');

$selectorder = <<<ORDER 
function(rowid, selected) 
{ 
    if(rowid != null) { 
        alert("selected: "+rowid); 
    } 
} 
ORDER;
$grid->setGridEvent('onSelectRow', $selectorder);

What is causing this error?

导致此错误的原因是什么?

I personally don't know what <<< does and have never used it, I got it from a tutorial. I tried to google it, but you can't google characters like that :(

我个人不知道<< <做了什么,从未使用过它,我是从教程中得到的。我试着谷歌它,但你不能像那样谷歌字符:(< p>

6 个解决方案

#1


49  

Check for whitespace after <<<ORDER. There should be no blank characters.

在<<< ORDER之后检查空格。应该没有空白字符。

#2


4  

<<< is for heredoc: See manual

<< <适用于heredoc:参见手册< p>

#3


1  

Make sure that there is no SPACE/INDENTATION before ending ORDER;

在结束ORDER之前确保没有SPACE / INDENTATION;

#4


1  

PHP Heredoc does not get on well with the % symbol, and the following also causes Parse error: syntax error, unexpected T_SL:

PHP Heredoc与%符号不兼容,以下也会导致Parse错误:语法错误,意外T_SL:

<?php
$var=<<<%%SHRUBBERY%%

Nih!

%%SHRUBBERY%%;
?>

#5


1  

Also make sure that you have 3 '<<<'. Omitting one will throw this error. Also if your using NOWDOCs, make sure your hosting provider has php 5.3 installed. Plus if your php environment is below 5.3, do not use double quotes or single quotes.

还要确保你有3'<<<'。省略一个将抛出此错误。此外,如果您使用NOWDOC,请确保您的托管服务提供商已安装php 5.3。另外,如果您的php环境低于5.3,请不要使用双引号或单引号。

#6


0  

It's called "Heredoc syntax", and it lets you specify large strings without using quotes. In this case, it looks like you're using it to put JavaScript code into a variable. Since you started the string with <<<ORDER, you should be able to finish it with ORDER;, as you have — but you need to make sure that ORDER; occurs at the start of a line, with no whitespace before it.

它被称为“Heredoc语法”,它允许您指定大字符串而不使用引号。在这种情况下,看起来您正在使用它将JavaScript代码放入变量中。因为你用<<< ORDER开始了字符串,所以你应该能够用ORDER完成它,就像你一样 - 但是你需要确保ORDER;发生在一行的开头,前面没有空格。

#1


49  

Check for whitespace after <<<ORDER. There should be no blank characters.

在<<< ORDER之后检查空格。应该没有空白字符。

#2


4  

<<< is for heredoc: See manual

<< <适用于heredoc:参见手册< p>

#3


1  

Make sure that there is no SPACE/INDENTATION before ending ORDER;

在结束ORDER之前确保没有SPACE / INDENTATION;

#4


1  

PHP Heredoc does not get on well with the % symbol, and the following also causes Parse error: syntax error, unexpected T_SL:

PHP Heredoc与%符号不兼容,以下也会导致Parse错误:语法错误,意外T_SL:

<?php
$var=<<<%%SHRUBBERY%%

Nih!

%%SHRUBBERY%%;
?>

#5


1  

Also make sure that you have 3 '<<<'. Omitting one will throw this error. Also if your using NOWDOCs, make sure your hosting provider has php 5.3 installed. Plus if your php environment is below 5.3, do not use double quotes or single quotes.

还要确保你有3'<<<'。省略一个将抛出此错误。此外,如果您使用NOWDOC,请确保您的托管服务提供商已安装php 5.3。另外,如果您的php环境低于5.3,请不要使用双引号或单引号。

#6


0  

It's called "Heredoc syntax", and it lets you specify large strings without using quotes. In this case, it looks like you're using it to put JavaScript code into a variable. Since you started the string with <<<ORDER, you should be able to finish it with ORDER;, as you have — but you need to make sure that ORDER; occurs at the start of a line, with no whitespace before it.

它被称为“Heredoc语法”,它允许您指定大字符串而不使用引号。在这种情况下,看起来您正在使用它将JavaScript代码放入变量中。因为你用<<< ORDER开始了字符串,所以你应该能够用ORDER完成它,就像你一样 - 但是你需要确保ORDER;发生在一行的开头,前面没有空格。