note 118269 added to function.intval

From: Date: Fri, 06 Nov 2015 15:48:39 +0000
Subject: note 118269 added to function.intval
Groups: php.notes 
Request: Send a blank email to php-notes+get-204095@lists.php.net to get a copy of this message
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 ---- Server IP: 72.52.91.14 Probable Submitter: 37.27.26.110 ---- Manual Page -- http://php.net/manual/en/function.intval.php Edit -- https://master.php.net/note/edit/118269 Del: integrated -- https://master.php.net/note/delete/118269/integrated Del: useless -- https://master.php.net/note/delete/118269/useless Del: bad code -- https://master.php.net/note/delete/118269/bad+code Del: spam -- https://master.php.net/note/delete/118269/spam Del: non-english -- https://master.php.net/note/delete/118269/non-english Del: in docs -- https://master.php.net/note/delete/118269/in+docs Del: other reasons-- https://master.php.net/note/delete/118269 Reject -- https://master.php.net/note/reject/118269 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204095) next »