Skip to content
This repository was archived by the owner on Nov 11, 2019. It is now read-only.

Commit 22e8ea9

Browse files
committed
Added example files
1 parent 76f2a4d commit 22e8ea9

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

examples/date.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
/* VALID FORMAT */
6+
7+
$raw = '10/01/2014';
8+
9+
$filtered = Filter\Filter::date($raw);
10+
11+
echo 'yyyy/mm/dd: ' . $filtered . PHP_EOL;
12+
13+
/* INVALID FORMAT */
14+
15+
$raw = '32/01/2000';
16+
17+
$filtered = Filter\Filter::date($raw);
18+
19+
if (is_null($filtered))
20+
echo 'Invalid date format.' . PHP_EOL;
21+
else
22+
echo 'This is not going to be displayed.' . PHP_EOL;

examples/numeric.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
/* USING DOT */
6+
7+
$raw = '10.2';
8+
9+
/* INTEGER */
10+
11+
echo Filter\Filter::int($raw) . PHP_EOL;
12+
13+
/* FLOAT */
14+
15+
echo Filter\Filter::float($raw) . PHP_EOL;
16+
17+
/* USING COMMA */
18+
19+
$raw = '10,2';
20+
21+
/* INTEGER */
22+
23+
echo Filter\Filter::int($raw) . PHP_EOL;
24+
25+
/* FLOAT */
26+
27+
echo Filter\Filter::float($raw) . PHP_EOL;

examples/strings.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
/* RAW STRING */
6+
7+
$raw = '<script>alert();</script>';
8+
9+
echo Filter\Filter::string($raw) . PHP_EOL;
10+
11+
/* NO TAGS */
12+
13+
echo Filter\Filter::noTags($raw) . PHP_EOL;

0 commit comments

Comments
 (0)