Skip to content

Fishbite/php-dom-htmldocument-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP 8.4+ DOM\HTMLDocument Examples

This project demonstrates usage of the new DOM\HTMLDocument class introduced in PHP 8.4+. It shows how to parse and extract parts of an HTML document using native DOM manipulation.

Requirements

  • PHP 8.4+ with DOM extension enabled
  • Composer (for autoloading if needed)

Files

  • extract_head.php — prints the first element inside <head>
  • extract_title.php — extracts the <title> tag text
  • list_meta.php — lists all <meta> tags in <head>
  • html/sample.html — test HTML file

Run

php examples/extract_head.php
php examples/extract_title.php
php examples/list_meta.php

Make sure the current working directory structure is correct:

project-root/
├── examples/
│   ├── extract_head.php
│   ├── extract_title.php
│   └── list_meta.php
├── html/
│   └── sample.html
└── vendor/
    └── autoload.php

Note: These examples assume you're running PHP 8.4+ with native DOM\HTMLDocument support.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages