PHP code example of russsiq / laravel-dom-manipulator

1. Go to this page and download the library: Download russsiq/laravel-dom-manipulator 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/ */

    

russsiq / laravel-dom-manipulator example snippets


Russsiq\DomManipulator\ManipulatorServiceProvider::class,

'DOMManipulator' => Russsiq\DomManipulator\Facades\DOMManipulator::class,

DOMManipulator::someMethod(example $someParam);

use Russsiq\DomManipulator\Facades\DOMManipulator;

// Предположим некое содержимое.
$content = '<h2>Velit rerum aut adipisci eius et est deserunt et et error</h2>'.PHP_EOL;
$content .= '<p>Dolore quidem <strong>dolorem</strong> ratione aut similique qui.</p>'.PHP_EOL;
$content .= '<pre>$manipulator = $this->createManipulator();</pre>'.PHP_EOL;
$content .= '<script>alert("Hello!");</script>'.PHP_EOL;

// Обернем содержимое как HTML-документ.
$result = DOMManipulator::wrapAsDocument($content)
    // Скорректируем теги `pre`.
    ->revisionPreTag()
    // Удалим нежелательные теги с их значениями.
    ->remove('script');

// Распечатаем результат.
print_r((string) $result);

// <h2>Velit rerum aut adipisci eius et est deserunt et et error</h2>
// <p>Dolore quidem <strong>dolorem</strong> ratione aut similique qui.</p>
// <pre class="ql-syntax" spellcheck="false">$manipulator = $this-&gt;createManipulator();</pre>