casting vs is_numeric in php

The casting is to define data type to specific variable in which may be set or going to be set
example:
$sam = (string)$_POST['name'];
 here (string) is the casting type in php.The casting type can be used as sanitizing the varible from sql injection.

$val = (int)$_GET['id'];


is better then

$val = $_GET['id']  ;

The is_numeric is function used to validate the integer variable.
The casting is faster then is_numeric ,because is_numeric returns boolean (true or false) and its a function where casting returns  numeric value.


Comments

Popular posts from this blog

create pdf by using javascript

yii framework simple shopping cart tutorial for beginners

yii2 arrayhelper::map vs array_map