Parse error: syntax error, unexpected T_SL PHP heredoc

╄→гoц情女王★ 提交于 2019-12-12 10:43:38

问题


I keep getting the following error:

Parse error: syntax error, unexpected T_SL in /home/a4999406/public_html/willingLog.html on line 70

on the following code (first line is line 70):

        echo <<<END 
<form action = "willingLog.html" method="post"><pre>
    First       <input type="text" name="first" />
    Last        <input type="text" name="last" />
    Email       <input type="text" name="email" />
    Username    <input type="text" name="user_name" />
                <input type="submit" value="AD RECORD" />
</pre></form>
END;

heredoc just doesn't seem to work. i've tried other examples.

following is by doctype heading. is there something wrong there?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

回答1:


Looking at the copy-paste, it looks like you have a space character after the word "END" on the first line:

'echo <<<END '

Try getting rid of the space character. Answer found by Googling. Source (link now dead): http://www.alexxoid.com/blog/dev/php-dev/php-parse-error-unexpected-t_sl.html




回答2:


Try:

echo <<<'END'
<form action = "willingLog.html" method="post"><pre>
    First       <input type="text" name="first" />
    Last        <input type="text" name="last" />
    Email       <input type="text" name="email" />
    Username    <input type="text" name="user_name" />
                <input type="submit" value="AD RECORD" />
</pre></form>
END;


来源:https://stackoverflow.com/questions/11208725/parse-error-syntax-error-unexpected-t-sl-php-heredoc

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