PHP code example of originphp / html

1. Go to this page and download the library: Download originphp/html 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/ */

    

originphp / html example snippets


$text = <<< EOF
This is a paragrpah.
This is another line part of the paragraph.

This is a new paragraph.
EOF;
$html = Html::fromText($text);

$html = Html::fromText($text,['tag'=>'div']);

$text = Html::toText($html);

$html = <<< EOF
<h1>Search Engines</h1>
<h2>Google</h2><h3>About</h3>
<blockquote>Google is not a conventional company. We do not intend to become one.</blockquote>
<p>Google LLC is an American        multinational technology 
company that specializes in Internet-related services and products, which include online advertising technologies, search engine, cloud computing, software, and hardware.<br>It is considered one of the Big Four technology companies, alongside Amazon, Apple and Facebook.</p>
<p>Benefits of using Google:</p>
<ol>
    <li>Good quality search results</li>
    <li>Relevent advertising</li>
</ol>
<p>Important links:</p>
<ul>
    <li><a href="https://en.wikipedia.org/wiki/Google">Google's Wikipedia Page</a></li>
    <li><a href="https://abc.xyz/">Alphabet</a></li>
</ul>
<h3>Financial Results</h3>
<p>Below are the <span>financial</span> results for the last <em>3 years</em>.</p>
<table>
<tr>
        <th>Revenue</th>
        <th>31/12/2018</th>
        <th>31/12/2017</th>
        <th>31/12/2016</th>
</tr>
<tr>
        <td>Total revenue</td>
        <td>136,819,000</td>
        <td>110,855,000</td>
        <td>90,272,000</td>
</tr>
<tr>
        <td>Cost of revenue</td>
        <td>59,549,000</td>
        <td>45,583,000</td>
        <td>35,138,000</td>
</tr>
<tr>
        <td>Gross profit</td>
        <td><strong>77,270,000</strong></td>
        <td><strong>65,272,000</strong></td>
        <td><strong>55,134,000</strong></td>
</tr>
</table>
<h3>Using Google API</h3>
<p>You can use the <a href="https://github.com/googleapis/google-api-php-client/tree/master/examples">Google API</a> to access various Google services.</p>
<p>To install the library:</p>
<pre>
<code>composer 

$text = Html::toText($html,['format'=>false]);

$minified = Html::minify($html);

$html = Html::sanitize($html,[
    'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
    'p',
    'i', 'em', 'strong', 'b', 'blockquote', 'del',
    'a' => ['href'],
    'ul', 'li', 'ol', 'br',
    'code', 'pre',
    'img' => ['src','alt']]
    );

$html = Html::stripTags($html,['script','iframe','img']);

$escaped = Html::escape($html);