PHP code example of italystrap / cleaner
1. Go to this page and download the library: Download italystrap/cleaner 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/ */
italystrap / cleaner example snippets
$sanitizator = new \ItalyStrap\Cleaner\Sanitization();
$validator = new \ItalyStrap\Cleaner\Validation();
$sanitizator->addRules( 'trim' );
// `Test`
echo $sanitizator->sanitize( ' Test ' );
// Single string rule
$rule = 'trim';
$sanitizator->addRules( $rule );
// `Test`
echo $sanitizator->sanitize( ' Test ' );
// Multiple rules in string
$rules = 'strip_tags|trim';
$sanitizator->addRules( $rules );
// `Test`
echo $sanitizator->sanitize( ' <p> Test </p> ' );
// Multiple rules string in array
$rules_arr = [
'strip_tags',
'trim',
];
$sanitizator->addRules( $rules_arr );
// `Test`
echo $sanitizator->sanitize( ' <p> Test </p> ' );
$callback = function ( $value ) {
return 'New value from callback';
};
// Callable rule in array
$rule_callable = [
$callback
];
$sanitizator->addRules( $rule_callable );
// `New value from callback`
echo $sanitizator->sanitize( ' <p> Test </p> ' );
// Multiple callable rules in array
$rules_callable = [
$callback,
$callback,
];
$sanitizator->addRules( $rules_callable );
// `New value from callback`
echo $sanitizator->sanitize( ' <p> Test </p> ' );