Doc #74727 [Ver->Csd]: Values in $_GET/POST are always strings

From: Date: Fri, 11 Aug 2017 18:54:32 +0000
Subject: Doc #74727 [Ver->Csd]: Values in $_GET/POST are always strings
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14889@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74727&edit=1 ID: 74727 Updated by: patrickallaert@php.net Reported by: kmgkumar28 at gmail dot com Summary: Values in $_GET/POST are always strings -Status: Verified +Status: Closed Type: Documentation Problem Package: Variables related Operating System: Windows 7 PHP Version: 7.2.0alpha1 -Assigned To: +Assigned To: patrickallaert Block user comment: N Private report: N New Comment: The fix for this bug has been committed. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Documentation was indeed a bit misleading, added a comment on the fact that everything coming as strings per the HTTP protocol, PHP doesn't apply any kind of conversion on those input. Fixed in the documentation as per SVN revision r342844. Previous Comments: ------------------------------------------------------------------------ [2017-08-11 18:49:48] patrickallaert@php.net Automatic comment from SVN on behalf of patrickallaert Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=342844 Log: Fixed: doc bug 74727 ------------------------------------------------------------------------ [2017-06-09 13:18:16] cmb@php.net > I don't actually see this documented, though I do think it has > been somewhere... Actually, the section "Determining variable types"[1] is even rather misleading. [1] <https://secure.php.net/manual/en/language.variables.external.php#language.variables.determining-type-of> ------------------------------------------------------------------------ [2017-06-09 12:31:38] xpigeon at 163 dot com May be some Error in your form? Your will edit the form like as <form action="?" method="post"> or <form action="?" method="get"> test it again. ------------------------------------------------------------------------ [2017-06-09 11:34:09] requinix@php.net As the new summary says, values in $_GET and $_POST are strings. Well, strings or arrays. Naturally that is the same for $_REQUEST. And it's the case for $_COOKIE too. And even $_SERVER and $_ENV. Anyways, PHP will not try to determine integers or floats, and definitely will not interpret the string "null" to be literally NULL. I don't actually see this documented, though I do think it has been somewhere... https://secure.php.net/manual/en/language.variables.external.php ------------------------------------------------------------------------ [2017-06-09 11:02:48] kmgkumar28 at gmail dot com Description: ------------ In Using The following code the datatype does not returns correctly in output. i sent name value in '123' in html page but here i will only get string value, in similar results in if i set name = 12.32 , null. <html> <form name = "post" > <input type = "text" name = "name" /> <input type = "submit" name = "submit" /> <?php echo gettype($_POST['name']); ?> Expected result: ---------------- 1) if i set the html text box value as number it returns integer 2) if i set the html text box value as text it returns string 3) if i set the html text box value as null it returns NULL Actual result: -------------- 1) i set the html text box value as number it returns string 2) i set the html text box value as text it returns string 3) i set the html text box value as null it returns string ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74727&edit=1

« previous php.doc.bugs (#14889) next »