Archive

Posts Tagged ‘Filter’

FILTER_SANITIZE_URL

Remove all unwanterd characters form a URL

Example
======

<?php
$url=”http://www.phpcoåødez.com”;
echo filter_var($url, FILTER_SANITIZE_URL);
?>

Output
=====

http://www.phpcodez.com

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Filter Tags: ,

FILTER_VALIDATE_BOOLEAN

Return TRUE for “true”, “1″, “on” and “yes”, FALSE for “0″,”false”, “off”, “no”, and “”, NULL otherwise

Example
======

<?php
echo filter_var(“Yes”, FILTER_VALIDATE_BOOLEAN);
?>

Output
=====

1

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Filter Tags: ,

FILTER_UNSAFE_RAW

Removes characters that is potentially harmful for your application

Example
======

<?php
echo filter_var(“PHPCodez’”, FILTER_UNSAFE_RAW);
?>

Output
=====

PHPCodez\’

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Filter Tags: ,

FILTER_SANITIZE_MAGIC_QUOTES

It adds slashes before quotes

Example
======

<?php
echo filter_var(“PHPCodez’”, FILTER_SANITIZE_MAGIC_QUOTES);
?>

Output
=====

PHPCodez\’

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Filter Tags: ,

FILTER_SANITIZE_NUMBER_FLOAT

Remove all illegal characters from a float number

Example
======

<?php
echo filter_var(“1-7php+5.4Codez”, FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
?>

Output
=====

1-7+5.4

Possible flags:

FILTER_FLAG_ALLOW_SCIENTIFIC – Separate fraction with e and E)

FILTER_FLAG_ALLOW_FRACTION – Separate fraction with “.”
FILTER_FLAG_ALLOW_THOUSAND – Separate fraction with “,”

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Filter Tags: ,

FILTER_SANITIZE_NUMBER_INT

Remove all illegal ineteger characters

Example
======

<?php
echo filter_var(“1php-7+Codez”, FILTER_SANITIZE_NUMBER_INT);
?>

Output
=====

1-7+

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Filter Tags: ,

FILTER_SANITIZE_EMAIL

Remove all illegal email characters

Example
======

<?php
echo filter_var(“info()@phpcodez.com”, FILTER_SANITIZE_EMAIL);
?>

Output
=====

info@phpcodez.com

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Filter Tags: ,

FILTER_SANITIZE_ENCODED

Encode special characters

Example
======

<?php
print_r(filter_var(“http://www.phpcodez.com”,FILTER_SANITIZE_ENCODED));
?>

Output
=====

http%3A%2F%2Fwww.phpcodez.com

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Filter Tags: ,

Switch to our mobile site