It prints parsable string representation of a variable
Example
======
<?php
echo “<pre>”;
$array = array(“php”,”codez”, array(“1”, “1”, “7”),1,2);
var_export($array);
?>
Output
=====
array (
0 => ‘php’,
1 => ‘codez’,
2 =>
array (
0 => ‘1’,
1 => ‘1’,
2 => ‘7’,
),
3 => 1,
4 => 2,
)
It displays structured information about one or more expressions .
Example
======
<?php
echo “<pre>”;
$array = array(“php”,”codez”, array(“1”, “1”, “7”),1,2);
var_dump($array);
?>
Output
=====
array(5) {
[0]=>
string(3) “php”
[1]=>
string(5) “codez”
[2]=>
array(3) {
[0]=>
string(1) “1”
[1]=>
string(1) “1”
[2]=>
string(1) “7”
}
[3]=>
int(1)
[4]=>
int(2)
}
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
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
Removes characters that is potentially harmful for your application
Example
======
<?php
echo filter_var(“PHPCodez'”, FILTER_UNSAFE_RAW);
?>
Output
=====
PHPCodez’
It adds slashes before quotes
Example
======
<?php
echo filter_var(“PHPCodez'”, FILTER_SANITIZE_MAGIC_QUOTES);
?>
Output
=====
PHPCodez’
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 “,”
Remove all illegal ineteger characters
Example
======
<?php
echo filter_var(“1php-7+Codez”, FILTER_SANITIZE_NUMBER_INT);
?>
Output
=====
1-7+
Remove all illegal email characters
Example
======
<?php
echo filter_var(“info()@phpcodez.com”, FILTER_SANITIZE_EMAIL);
?>
Output
=====
info@phpcodez.com
Encode special characters
Example
======
<?php
print_r(filter_var(“http://www.phpcodez.com”,FILTER_SANITIZE_ENCODED));
?>
Output
=====
http%3A%2F%2Fwww.phpcodez.com
Zend | Magento Certified PHP | eCommerce Architect