[
](LICENSE)

A small, object-oriented PHP library that provides a DOM-like API to build, manage and render xHTML pages programmatically. The library helps separate presentation structure from application logic by exposing HTML elements as PHP objects that can be composed, nested and rendered as compliant xHTML.
Highlights
- Lightweight OO approach to generate xHTML programmatically
- DOM-like tree model with element classes for common HTML tags
- Helpers for tables, unparsed blocks and structured content insertion
- Output is intended to be valid xHTML (e.g., xHTML 1.0 Transitional)
When to use
- You want clear separation between HTML structure and PHP logic
- You prefer building pages by composing elements instead of echoing HTML strings
- You need programmatic helpers for tables, fragments and unparsed HTML
Quick Start
- Include the library (use the
src folder or place files in your include path).
require_once 'src/xHTML_All.php';
Usage Example
The following example is preserved from the original repository and demonstrates basic usage and features.
<?php
require_once '/xHTML_All.php';
$webPage->AddCSSFile("some-css-file.css");
$header->SetID("header");
$footer->SetID("footer");
$contentMainDiv->SetID("content");
$webPage->AddContent($header);
$webPage->AddContent($footer);
$footer->AddContentBefore($contentMainDiv);
$contentMainDiv->AddContent(
new xHTML_P(
"Welcome to the xHTML-o-MATIC test page!"));
$contentMainDiv->AddContent(
new xHTML_UnparsedCode(
"<p>And also, it allows to add unparsed code by hand like this <a href='http://www.google.es'>google link</a> inside a p element</p>"));
$table->SetProperty("align", "center");
$table->SetProperty("border", "1");
$table->SetProperty("width", "60%");
$table->AddContentMatrix(0, 0,
new xHTML_P(
"This is cell 0,0"));
$table->AddContentMatrix(0, 1,
new xHTML_P(
"This is cell 0,1"));
$table->AddContentMatrix(1, 1, "This is cell 1,1");
$table->SetCellProperty(1, 1, "align", "right");
$webPage->AddContent($table);
$webPage->Render();
?>
Definition xHTML_Div.php:12
Definition xHTML_P.php:13
Definition xHTML_Page.php:12
Definition xHTML_Table.php:12
Definition xHTML_UnparsedCode.php:12
Available classes
- Core include:
src/xHTML_All.php to require all element classes
- Element classes included in the library (found in
src/):
W3COKButton.php
xHTML_A.php
xHTML_BR.php
xHTML_Base.php
xHTML_Body.php
xHTML_Comment.php
xHTML_Div.php
xHTML_Exceptions.php
xHTML_Form.php
xHTML_Generic.php
xHTML_H.php
xHTML_Head.php
xHTML_Img.php
xHTML_Link.php
xHTML_List.php
xHTML_P.php
xHTML_Page.php
xHTML_Script.php
xHTML_Span.php
xHTML_Style.php
xHTML_Table.php
xHTML_Text.php
xHTML_UnparsedCode.php
Documentation
- Full generated documentation is available in the
docs/ folder. Open docs/index.html in a browser to browse the API and examples.
Installation and integration
- There is no installer; copy the
src/ folder into your project and ‘require_once 'src/xHTML_All.php’` from your bootstrap or script.
- The library is plain PHP and has no external dependencies.
Contributing
- Contributions are welcome. Please open issues or pull requests with clear descriptions and tests where appropriate.
License
- This project is licensed under the GNU General Public License v3.0. See the
LICENSE file for details.
Support
- For questions or issues, please open an issue in the repository.