1. Go to this page and download the library: Download makis83/helpers library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$isHtml = Html::isHTML('This is a simple text.'); // false
$isHtml = Html::isHTML('<p>This is a simple paragraph.</p>'); // true
$isHtml = Html::isHTML('This is a <simple> text & more.'); // true
// Simple text
$secured = Html::secure('This is a simple text.');
// Result: "This is a simple text."
// Text with HTML-like entities
$secured = Html::secure('This is a "simple" text with entities & smth else™.');
// Result: "This is a "simple" text with entities & smth else™."
// HTML with purification
$secured = Html::secure('<p>This is a <b>simple</a> paragraph.</p><img src="javascript:evil();" onload="evil();" />');
// Result: "<p>This is a <b>simple paragraph.</b></p>"
// Simple text
$tidied = Html::tidy('This is a simple text.');
// Result: "This is a simple text."
// HTML with correct structure
$tidied = Html::tidy('<p>This is a <b>simple</b> paragraph.</p>');
// Result: "<p>This is a <strong>simple</strong> paragraph.</p>\n"
// HTML with incorrect structure
$tidied = Html::tidy('<p class="aaa" class="bbb">This is a <b>simple</a> paragraph.</p>');
// Result: "<p class=\"aaa bbb\">This is a <strong>simple paragraph.</strong></p>\n"
// Simple text without line breaks
$html = Html::textToHtml('This is a simple text without line breaks.');
// Result: "<p>This is a simple text without line breaks.</p>\n"
// Text with line breaks
$html = Html::textToHtml("This is a simple text\nwith single line breaks.");
// Result: "<p>This is a simple text<br />\nwith single line breaks.</p>\n"
// Multiple paragraphs
$html = Html::textToHtml("This is the first paragraph.\n\nThis is the second paragraph, with a line break.\nSee?\n\nThis is the third paragraph.");
// Result: "<p>This is the first paragraph.</p>\n<p>This is the second paragraph, with a line break.<br />\nSee?</p>\n<p>This is the third paragraph.</p>\n"
// Simple text
$tags = Html::textTags('This is a simple text.');
// Result: []
// Simple HTML
$tags = Html::textTags('<p>This is a <b>simple</b> paragraph.</p>');
// Result: ['p', 'b']
// Complex HTML
$tags = Html::textTags('<div><h1>Title</h1><p>Paragraph with <a href="#">link</a> and <span style="color:red;">styled text</span>.<img src="image.jpg" /></p></div>');
// Result: ['div', 'h1', 'p', 'a', 'span', 'img']
// Basic usage
$fixed = Text::fixSpaces('This is a test.'); // Returns: "This is a test."
// With NBSPs
$fixed = Text::fixSpaces("This is a test."); // Returns: "This is a test."
$fixed = Text::fixSpaces("This \xC2\xA0 is \xC2\xA0 a \xC2\xA0 test."); // Returns: "This is a test."
// With narrow NBSPs
$fixed = Text::fixSpaces("This \xE2\x80\xAF is \xE2\x80\xAF a \xE2\x80\xAF test."); // Returns: "This is a test."
// With RLM characters
$fixed = Text::fixSpaces("This \xE2\x80\x8F is \xE2\x80\x8F\xe2\x80\x8a a \xE2\x80\x8F test.\xe2\x80\x83"); // Returns: "This is a test."
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.