<?php require_once __DIR__ . '/../vendor/autoload.php'; /* VALID FORMAT */ $raw = '10/01/2014'; $filtered = Filter\Filter::date($raw); echo 'yyyy/mm/dd: ' . $filtered . PHP_EOL; /* INVALID FORMAT */ $raw = '32/01/2000'; $filtered = Filter\Filter::date($raw); if (is_null($filtered)) { echo 'Invalid date format.' . PHP_EOL; } else { echo 'This is not going to be displayed.' . PHP_EOL; }
<?php require_once __DIR__ . '/../vendor/autoload.php'; /* USING DOT */ $raw = '10.2'; /* INTEGER */ echo Filter\Filter::int($raw) . PHP_EOL; /* FLOAT */ echo Filter\Filter::float($raw) . PHP_EOL; /* USING COMMA */ $raw = '10,2'; /* INTEGER */ echo Filter\Filter::int($raw) . PHP_EOL; /* FLOAT */ echo Filter\Filter::float($raw) . PHP_EOL;
<?php require_once __DIR__ . '/../vendor/autoload.php'; /* RAW STRING */ $raw = '<script>alert();</script>'; echo Filter\Filter::string($raw) . PHP_EOL; /* NO TAGS */ echo Filter\Filter::noTags($raw) . PHP_EOL;