hugsbrugs / php-html
PHP HTML Utilities
Installs: 69
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:HTML
Requires
- h0gar/xpath: ^0.1.4
- hugsbrugs/php-string: dev-master
- hugsbrugs/php-xpath: dev-master
This package is auto-updated.
Last update: 2024-10-20 14:56:34 UTC
README
This librairy provides utilities function to ease HTML manipulation
Install
Install package with composer
composer require hugsbrugs/php-html
In your PHP code, load librairy
require_once __DIR__ . '/vendor/autoload.php'; use Hug\Html\Html as Html;
Usage
Test if a link is external from given domain
$bool = Html::is_external_link($domain = 'maugey.fr', $link = 'http://maugey.fr/coucou.html');
Test if a link is from given domain
$bool = Html::is_domain_link($domain = 'tata.maugey.fr', $link = 'http://maugey.fr/coucou.html');
Replace all relatives path in HTML (script, style, img) with absolute ones with given page URL
$html = Html::replace_rel_to_abs_paths($html, $page_url = 'http://portail.free.fr/m/');
Build an absolute link from relative link and page URL
$html = Html::rel_to_abs($rel = '/js/script.js', $base = 'http://portail.free.fr/m/');
Return array of backlinks from given HTML page and domain
$html = Html::find_backlinks($html, $domain = 'www.free.fr');
Returns array of canonicals from string
$array = Html::get_canonicals($canonical_content = 'index, follow, noindex, noarchive');
Replaces all links in HTML by https
$html = Html::set_href_ssl($html);
Set UTF-8 Charset in HTML page with correct syntax depending on Doctype
$html = Html::set_charset_utf_8($html);
Remove all external link from HTML with given domain
$html = Html::remove_external_links($html, $domain = 'free.fr');
Remove all and <style> tags from HTML
$html = Html::remove_script_style($html);
Extract content from HTML page
$body = Html::extract_body_content($html);
Check for tag
$is_spa = Html::is_spa($html);
Get all links
$links = Html::get_links($html);
Get all iframes
$links = Html::get_iframes($html);
Get external links
$external_links = Html::get_external_links($html);
Get internal links
$internal_links = Html::get_internal_links($html);
Get images
$images = Html::get_images($html);
Obfuscate email to be incorporated in HTML
$email = Html::DJNikMail($str = 'tatayoyo@free.fr');
Unit Tests
phpunit --bootstrap vendor/autoload.php tests
Author
Hugo Maugey visit my website ;)