can i do something like this on xhtml?
if so, how? thank you.Code:<?php include "some.php" ?>
Printable View
can i do something like this on xhtml?
if so, how? thank you.Code:<?php include "some.php" ?>
yes you can. the PHP can still insert XHTML. here's an example:
PHP Code:<?
include "header.php";
?>
<p>
More code can go here.
</p>
<hr />
<p>
This causes noproblem at all. the PHP simply pulls more code from the included files. Just make sure that the code from them is valid. Of course the page will still show if it's not.
</p>
PHP just generates text. It's up to you to ensure that this text is well-formed XHTML.
sorry for the misleading fellas. sorry about my english. what i want to know is actually the include feature of php, if there's any in xhtml. something like modularizing.
can i have something like that in xhtml? say, i save a TOC.XHTML and i want to put it in a certain divCode:<?php include "some.php" ?>
hope i clear myself up. thank you.Code:<div>
<!-- include TOC.XHTML -->
</div>
not in XHTML itself, but you can just use PHP again.
PHP Code:<div>
<? include "div_contents.php"; ?>
</div>
ah ok. thank you very much. so, there's none in xhtml about including stuff. thank you thank you.
There are various methods, but none is really XHTML.
1) PHP or other script includes.
2) Server-Side Includes (SSI). You just have to reconfigure your server a bit to make it work.
These two actually work. The following are theory.
3) Since XHTML is XML, this should work:
The problem is that no browser I know of actually applies external parsed entities.Code:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "..." "..." [
<!ENTITY header SYSTEM "http://mydomain/includes/header.ent">
]>
<html xmlns="...">
<head>
</head>
<body>
&header;
</body>
</html>
4) The XLink specification has a way of directly putting stuff into a document.
Again, there's zero browser support for this. Mozilla will go farthest in that it might make a normal clickable link to header.xhtml out of this.Code:<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="..." xmlns:xlink="...">
<head></head>
<body>
<div id="menu" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" xlink:href="includes/header.xhtml"/>
</body>
</html>
5) XIncludes. This is another way of getting data into a document, and it's just as poorly supported as the other methods.
Code:<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="..." xmlns:xinc="...">
<head></head>
<body>
<xinc:include href="includes/header.xhtml" parse="xml"><xinc:fallback>
<h1>Header</h1>
</xinc:fallback></xinc:include>
<body>
</html>