1. Go to this page and download the library: Download vstelmakh/url-highlight 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/ */
use VStelmakh\UrlHighlight\Encoder\HtmlSpecialcharsEncoder;
use VStelmakh\UrlHighlight\UrlHighlight;
use VStelmakh\UrlHighlight\Validator\Validator;
$validator = new Validator();
$encoder = new HtmlSpecialcharsEncoder();
$urlHighlight = new UrlHighlight($validator, null, $encoder);
use VStelmakh\UrlHighlight\UrlHighlight;
use VStelmakh\UrlHighlight\Validator\Validator;
$validator = new Validator(
true, // bool - if should use top level domain to match urls without scheme
[], // string[] - array of blacklisted schemes
[], // string[] - array of whitelisted schemes
true // bool - if should match emails (if match by TLD set to "false" - will match only "mailto" urls)
);
$urlHighlight = new UrlHighlight($validator);
use VStelmakh\UrlHighlight\Highlighter\HtmlHighlighter;
use VStelmakh\UrlHighlight\UrlHighlight;
$highlighter = new HtmlHighlighter(
'http', // string - scheme to use for urls matched by top level domain
[], // string[] - key/value map of tag attributes, e.g. ['rel' => 'nofollow', 'class' => 'light']
'', // string - content to add before highlight: {here}<a...
'' // string - content to add after highlight: ...</a>{here}
);
$urlHighlight = new UrlHighlight(null, $highlighter);
use VStelmakh\UrlHighlight\Encoder\HtmlSpecialcharsEncoder;
use VStelmakh\UrlHighlight\UrlHighlight;
$encoder = new HtmlSpecialcharsEncoder();
$urlHighlight = new UrlHighlight(null, null, $encoder);
$urlHighlight->highlightUrls('<a href="http://example.com">Example</a>');
// return: '<a href="<a href="http://example.com">http://example.com</a>">Example</a>'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.