Bug->Doc #74727 [Opn->Ver]: Values in $_GET/POST are always strings
| From: | requinix@php.net | Date: | Fri, 09 Jun 2017 11:34:11 +0000 |
| Subject: | Bug->Doc #74727 [Opn->Ver]: Values in $_GET/POST are always strings | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14771@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: requinix@php.net
Reported by: kmgkumar28 at gmail dot com
-Summary: Bug in gettype() function
+Summary: Values in $_GET/POST are always strings
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-Package: PHP Language Specification
+Package: Variables related
Operating System: Windows 7
PHP Version: 7.2.0alpha1
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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