aparichit Posted January 22, 2012 Share Posted January 22, 2012 Just let a code snippet,for example like this: <?phpvar_dump($_GET['num']);?><form method="get" action="<?=$_SERVER['PHP_SELF'] ?>">Insert numeric digit: <input type="text" name="num" /><br /><input type="submit" value="Submit Digit!" /></form> Now though I pass any numeric digit[say 5] through that form, it becomes a string in output [like: string(1) "5"].Can anyone tell me, Why this problem occurs & How do I turn that in numeric again? Link to comment Share on other sites More sharing options...
Ingolme Posted January 22, 2012 Share Posted January 22, 2012 All input data is considered a string because there is nothing in the HTTP protocol indicating what data type the query string parameters are. You can cast it to an integer using the intval() function. $_GET['num'] = intval($_GET['num']); Link to comment Share on other sites More sharing options...
aparichit Posted January 22, 2012 Author Share Posted January 22, 2012 Hmm, I understood now! Thanks:-) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.