In PHP understand the differences between the use of print EOT delimiter and echo EOT

  • 2020-03-31 20:26:12
  • OfStack

In both HTML and PHP, echo can output multiple strings at the same time, without the need for parentheses.
Print can print only one string at a time, requiring parentheses.
Print is used in much the same way as C, so it does a special interpretation of % in the output.
Echo has no return value, print() has a return value, and returns flase when its execution fails (such as broken line).
Echo can have multiple parameters, and print can have one parameter. Echo is recommended.

Look at the following example to see how print < < < What is EOT for?
 
print <<<EOT 
<html> 
<head></head> 
<body> 
$value; 
<img src="$img"> 
... 
</body> 
<html> 
EOT; 

Meaning:
< < < Operator that treats the content between custom delimiters as a string and handles the variables between them.
EOT custom delimiter, must end at the beginning of the line;
Use < on the same page < < tag
Mark;
Note: the tag name is paired. More than two tag names with the same name are not allowed on the same page.
Also: the end tag name of the matched tag name should be a separate line, before and after are not allowed to output characters... Invisible but existing characters such as Spaces.. .
Advantage: this can output large segments of HTML and does not escape the inside quotes, which automatically replace the inside variables without using \".

How to output HTML code (EOT) in PHP
The PHP code

<?php 
echo <<< EOT 
<table width=80% border="2" cellpadding="3" cellspacing="0" bordercolor="#808080"> 
<tr bgcolor="#84A9E1"> 
<td align="center">ClassID</td> 
<td align="center">stuno</td> 
<td align="center"> The student's name </td> 
<td align="center"> Parents names </td> 
<td align="center"> Mobile phone number of parents </td> 
</tr> 
EOT; 
?> 

Reference: (link: #)

Related articles: