Home  >  Article  >  Backend Development  >  PHP learning—errors caused by delimiter format_PHP tutorial

PHP learning—errors caused by delimiter format_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:43:471021browse

The following is an incorrect code. Can you see where it went wrong? ? For a beginner like me, everything is vague and I really don’t know where to start. But I really have to try it myself to know what I’m doing wrong. Books and tutorials won’t tell me what I’m doing wrong

Error code: Parse error: syntax error, unexpected $end

in H:wampwww esting est2.1.4.php on line 16

Error source code:

$str = <<


Test string


Test string

Test string 

EOD;

echo $str;//Variables used to define delimiters

$name = Einstein;$dicta = "Imagination is more important than knowledge, because knowledge is limited, but imagination is unlimited";

$size = 5;

echo <<


said:"{$dicta}" 

EOT;

?>

Eclipse error pictures

PHP learning—errors caused by delimiter format_PHP tutorial

Error picture

This error is actually very simple, that is, at the end of the delimiters EOD and EOT, a Tab is added in front. The solution is to write "EOD;" and "EOT;" in the top box. I believe all beginners have the same experience as me...


Correct code:


$str = <<


Test string

Test string

Test string 

EOD;

echo $str;

//Variable used for delimiter definition $name = Einstein;

$dicta = "Imagination is more important than knowledge, because knowledge is limited, but imagination is unlimited";

$size = 5;

echo <<


said:"{$dicta}" 

EOT;

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478802.htmlTechArticleThe following is an incorrect code. Can you see where it went wrong? ? For a beginner like me, everything is vague and I really don’t know where to start, but I really have to try it myself to know where to go...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn