PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Everton da Rosa   DOM HTML Element   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example of use
Class: DOM HTML Element
Manipulate HTML page elements using DOM Document
Author: By
Last change: new methods added
Date: 8 years ago
Size: 805 bytes
 

Contents

Class file image Download
<html>
    <head>
        <title>HTMLElement test</title>
    </head>
    <body>
        <?php

       
require_once 'htmlelement.class.php';

       
$div = new HTMLElement('div');//create a main HTMLElement
       
$p = new HTMLElement('p');//create other HTMLElement
       
$p->appendChild(new DOMText('Test'));//append text to HTMLElement
       
$p->setAttribute('style', 'color: green');
       
$div->appendChild($p);//append child to main HTMLElement
       
$div->appendChild(new DOMElement('p', 'It\'s Work!'));//append a DOMElement to main HTMLElement
       
$div->setAttribute('style', 'color: red');
       
$code = $div->getCode();//get HTML code
       
echo $code;//show HTMLElement
       
highlight_string($code);//show source-code

       
?>
</body>
</html>