hugsbrugs/php-html

There is no license information available for the latest version (1.2) of this package.

PHP HTML Utilities

Installs: 66

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:HTML

1.2 2021-09-20 07:47 UTC

This package is auto-updated.

Last update: 2022-07-20 09:52:55 UTC


README

This librairy provides utilities function to ease HTML manipulation

Build Status Coverage Status

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 ;)