加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Heredoc不工作

发布时间:2020-12-13 13:14:47 所属栏目:PHP教程 来源:网络整理
导读:?php$information = INFO Name: John SmithAddress: 123 Main StCity: Springville,CAINFO;echo $information;? 结果: Parse error: syntax error,unexpected T_SL on line 3 解析器抱怨,因为在倾斜的括号中声明heredoc后,您有空格.您需要确保您实际遵循her
<?php

$information = <<<INFO 
Name: John Smith
Address: 123 Main St
City: Springville,CA
INFO;

echo $information;

?>

结果:

Parse error: syntax error,unexpected T_SL on line 3

解析器抱怨,因为在倾斜的括号中声明heredoc后,您有空格.您需要确保您实际遵循heredoc语法,您可以在PHP手册网站(具体来说: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc)找到它.
<?php
$information = <<<ENDHEREDOC
this is my text
ENDHEREDOC;
echo $information;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读