Monday, 16 March 2015
MySQL Notes
MS SQL Notes
CSS Notes
HTML Notes
JAVA Notes
PHP Notes
C++ Notes
C Language Notes
Thursday, 5 February 2015
Basic Library Files
C Language
C ++
C#.NET
ASP.NET
JAVA
PHP
MySQL
MS SQL Server
Oracle SQL
XML
Json
HTML (Hypertext Markup Language)
CSS (Cascading Stylesheet)
Javascript
DOM(Document Object Model) & BOM(Browser Object Model)
jQuery
Hadoop and Mapreduce Test
Saturday, 31 January 2015
Syllabus of PHP
PHP Tutorial
PHP Intro
PHP Install
PHP Syntax
PHP Variables
PHP Echo / Print
PHP Data Types
PHP Comment
PHP Strings
PHP Constants
PHP Operators
PHP If...Else
PHP If...Else...Elseif
PHP Switch
PHP While Loops
PHP For Loops
PHP Functions
PHP Arrays
PHP Sorting Arrays
PHP Superglobals
PHP Forms
PHP Form Handling
PHP Form Validation
PHP Form Required
PHP Form URL/E-mail
PHP Form Complete
Syllabus of CSS
CSS
CSS HOME
CSS Introduction
CSS Syntax
CSS Selectors
CSS How To
CSS Backgrounds
CSS Text
CSS Fonts
CSS Links
CSS Lists
CSS Tables
CSS Box Model
CSS Border
CSS Outline
CSS Margin
CSS Padding
CSS Dimension
CSS Display
CSS Positioning
CSS Floating
CSS Align
CSS Combinators
CSS Pseudo-class
CSS Pseudo-element
CSS Navigation Bar
CSS Image Gallery
CSS Image Opacity
CSS Image Sprites
CSS Media Types
CSS Attr Selectors
Sunday, 21 September 2014
PHP Filter
- Input data from a form
- Cookies
- Web services data
- Server variables
- Database query results
- filter_var() - Filters a single variable with a specified filter
- filter_var_array() - Filter several variables with the same or different filters
- filter_input - Get one input variable and filter it
- filter_input_array - Get several input variables and filter them with the same or different filters
|
<?php
$int = 123; if(!filter_var($int, FILTER_VALIDATE_INT)) { echo("Integer is not valid"); } else { echo("Integer is valid"); } ?> |
- Are used to validate user input
- Strict format rules (like URL or E-Mail validating)
- Returns the expected type on success or FALSE on failure
- Are used to allow or disallow specified characters in a string
- No data format rules
- Always return the string
|
<?php
$var=300; $int_options = array( "options"=>array ( "min_range"=>0, "max_range"=>256 ) ); if(!filter_var($var, FILTER_VALIDATE_INT, $int_options)) { echo("Integer is not valid"); } else { echo("Integer is valid"); } ?> |
|
<?php
if(!filter_has_var(INPUT_GET, "email")) { echo("Input type does not exist"); } else { if (!filter_input(INPUT_GET, "email", FILTER_VALIDATE_EMAIL)) { echo "E-Mail is not valid"; } else { echo "E-Mail is valid"; } } ?> |
- If the input variable exists, check if it is a valid e-mail address
|
<?php
if(!filter_has_var(INPUT_POST, "url")) { echo("Input type does not exist"); } else { $url = filter_input(INPUT_POST, "url", FILTER_SANITIZE_URL); } ?> |
|
http://www.W3Schools.com/
|
|
<?php
$filters = array ( "name" => array ( "filter"=>FILTER_SANITIZE_STRING ), "age" => array ( "filter"=>FILTER_VALIDATE_INT, "options"=>array ( "min_range"=>1, "max_range"=>120 ) ), "email"=> FILTER_VALIDATE_EMAIL, ); $result = filter_input_array(INPUT_GET, $filters); if (!$result["age"]) { echo("Age must be a number between 1 and 120.<br />"); } elseif(!$result["email"]) { echo("E-Mail is not valid.<br />"); } else { echo("User input is valid"); } ?> |
- Must be an associative array containing an input variable as an array key (like the "age" input variable)
- The array value must be a filter ID or an array specifying the filter, flags and options
|
<?php
function convertSpace($string) { return str_replace("_", " ", $string); } $string = "Peter_is_a_great_guy!"; echo filter_var($string, FILTER_CALLBACK, array("options"=>"convertSpace")); ?> |
|
Peter
is a great guy!
|