PHP code example of digiaonline / common-sanitization-stages
1. Go to this page and download the library: Download digiaonline/common-sanitization-stages 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/ */
digiaonline / common-sanitization-stages example snippets
nputData = <<<EOT
The quick brown fox<br />
jumped over the <i>incredibly lazy dog</i> & it
ran away.
EOT;
$encodedInputData = \base64_encode($rawInputData);
/** @var \League\Pipeline\Pipeline $pipeline */
$pipeline = (new \League\Pipeline\Pipeline())
->pipe(new \Digia\Sanitization\Stages\Base64DecodeStage())
->pipe(new \Digia\Sanitization\Stages\HtmlPurifierStage())
->pipe(new \Digia\Sanitization\Stages\HtmlEntityDecodeStage())
->pipe(new \Digia\Sanitization\Stages\StripLineFeedsStage(["\n"], true))
->pipe(new \Digia\Sanitization\Stages\TrimStringStage());
$outputData = $pipeline->process($encodedInputData);
var_dump($outputData); // string(70) "The quick brown fox jumped over the incredibly lazy dog & it ran away."