Insert a tag in the middle PHP XHTML
The PHP tag that we just discovered fits in the middle of XHTML as said earlier. Consider the example below
Code:
DOCTYPE html PUBLIC "name of the site and directory">
<html xmlns ="site name" xml: lang ="en" lang ="en">
<head>
<title> This is a test page </ title>
<meta http-equiv ="Content-Type" content ="text / html; charset = iso-8859-1" />
</ head>
<body>
<h2>Test </ h2>
<p>
This page contains code (x) HTML with PHP tags.<br />
<? php / * Insert PHP code here * / ?>
Here are some quick tests:
</ p>
<ul>
<li style ="color: blue;">Blue text</ li>
<li style ="color: red;">Text in red</ li>
<li style ="color: green;">Text in green</ li>
</ ul>
<? php
/ * Still PHP
Also PHP * /
?>
</ body>
</ html>
Of course this page does not work because we have not yet written real PHP code (they are simply markers for example). All you need to remember here is that when you want to put PHP code. We can put a PHP tag anywhere in the code, not just in the body of the page also you can put a PHP tag in the header of the page.
Code:
DOCTYPE html PUBLIC "site name and directory ">
<html xmlns ="site name" xml: lang ="en" lang ="en">
<head>
<title>This is a test page <? php / * PHP code * / ?></ title>
<meta http-equiv ="Content-Type" content ="text / html; charset = iso-8859-1" />
</ head>
Even more strange is, you can even insert a PHP tag in the middle of a tag XHTML.
Code:
DOCTYPE html PUBLIC "site name and directory ">
<html xmlns ="site name" xml: lang ="en" lang ="en">
<head>
<title>This is a test page</ title>
<meta http-equiv ="Content-Type" <? php / * PHP code * / ?> content ="text / html; charset = iso-8859-1" />
</ head>
Bookmarks