How to embed HTML code in PHP

1.Output HTML code with echo

<? php
Echo "< p > the random number obtained is 1 < / P >";
Echo "< p > the random number obtained is not 1 < / P >";

2.Embedding PHP in HTML code

In this way, you can add Code.

<! DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-CN" />
<title>Hello World</title>
<? php
Echo "Hello world! This is the text";

3.Use (< < <) markers

This is the first time I saw it in the template code of PHP168

      print <<<EOT
      <div class="slidecont">{$label[deepblue_mainslide]}</div>
     <div class="newcontainter">
          <div class="head">{$label[deepblue_mainh1]}</div>
          <div class="cont" id="Tab1">{$label[deepblue_maint1]}</div>
          <div class="cont" id="Tab2">{$label[deepblue_maint2]}</div>
      <a href="$rs[url]" title="$rs[descrip]" target="_blank">$rs[name]</a>

4.Directly reference HTML files into PHP

An HTML file (test. HTML), the main code is:

<p>I'm an HTML code</p>

Use PHP’s include () function to connect the external HTML file to the PHP file

<? php
include ("test.html");


Leave a Comment