note 118269 deleted from function.intval by cmb
| From: | cmb@php.net | Date: | Sun, 16 Feb 2020 13:46:53 +0000 |
| Subject: | note 118269 deleted from function.intval by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-214134@lists.php.net to get a copy of this message | ||
Note Submitter: Er.ellison
----
i guess one of the important usage of intval is in links , because :
imagine that u have a function that uses get method (for example an integer id ) to retrieve the
data from DB ,
so for example if you get " id=58 " in your link and put that in u'r function that
retrieves data from DB , that's fine , it works well
but what if some body put the " id=58djkdjsbvjkdsbvjkdbs " in the link ON PURPOSE !
in such situation and condition he will get an Database error
because u'r function retrieves Data from DB
so it good to be use intval in such situations
because if u use that u gonna be sure that what ever that passes from u'r DB related function
is just a integer , No text and any strange character !
let me show u by example
$id = 12dfjgdfjgnd;
echo $id // output will be : 12dfjgdfjgnd
echo intval($id) // output will be : 12