In W3school to school PHP, see the first sentence is "PHP files can contain text, HTML tags and scripts"
later in the study of other people's Code, found in the need for HTML code in the PHP script, the use of such several methods
First Kind is to add PHP to the HTML. Large sections of HTML code, where PHP is required to execute . This method is more common in ASP programs.
Example:
[Code_lite]
Hello World
echo "Hello world! This is the text";
?>
[/code_lite]
The second Kindoutput HTML with echo. However, there are double quotes in the HTML, and the contents of the echo output are enclosed in single quotes, avoiding errors and escaping this step. For example, this code:
[Code_lite]
if (!$_post)
{
Echo ' Description
';
}
? >[/code_lite]
but more than most of the more visible or add the escape symbol, the individual feel uncomfortable reading
[Code_lite]echo]"[/code_lite]
Third Kindis to use the (<<<) marker, which was first seen in PHP168 's template code.
[code_lite]<<
EOT; [/code_lite]
In the middle of the document output directly, a better understanding of the saying is "a multi-line echo."
The advantage is that the output of large pieces of HTML is convenient, does not need to be escaped, and can reference variables. An example:
[Code_lite]
!--? PHP
print <<
{$label [deepblue_mainslide]}
{$label [deepblue_mainh1]}
{$label [deepblue_maint1]}
{$label [Deepblue_maint2]}
$rs [name]
EOT;
? >[/code_lite]
The above example cleanly output the value of the large segment html+ variable, very good.
Note: You can use the EOT mode output multiple times, but <<
The above describes the PHP mixed three ways, including aspects of the content, I hope that the PHP tutorial interested in a friend to help.