PHP code example of netsilik / sanitizer

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

    

netsilik / sanitizer example snippets


// Instantiate sanitizer object
$sanitizer = new Sanitizer();

// Call signature
// $sanitizer->type(scalar $data, scalar $defaultValue = null, int $maxLength = -1, bool $silent = false);

// Sanitize some values
$a = $sanitizer->int('123');
$b = $sanitizer->utf8('hello, world');
$c = $sanitizer->bool(-1);
$d = $sanitizer->ascii(null, 'someDefault');
$e = $sanitizer->utf8('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', '', 26);

var_dump($a); // int(123)
var_dump($b); // string(12) "hello, world"
var_dump($c); // bool(false)
var_dump($d); // string(11) "someDefault"
var_dump($e); // string(26) "Lorem ipsum dolor sit amet"