PHP code example of maniruzzaman / sanitizer

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

    

maniruzzaman / sanitizer example snippets


// at top of the class autoload
use Maniruzzaman\Sanitizer\Sanitize;

// instantiate anywhere if needed
$sanitize = new Sanitize();

$string  = 'Text with script <script>alert("you are hacked...")</script>';
Sanitize::text($string);
#Output: Text with issuealert(&quot;you are hacked...&quot;)

$string  = 'Text with script <strong>This is strong text</strong>';
Sanitize::text($string);
#Output: Text with script This is strong text

$string  = 'https://devsenv.com<script>welcome</script>';

$sanitize = new Sanitize();
$sanitize->attr($string);
#Output: https:://devsenv.com

// For full directory
phpunit tests

// For specific file test
phpunit tests/SanitizeTest.php