Re: Lost data after space in PHP variables
| From: | Richard Quadling | Date: | Thu, 19 Feb 2015 13:27:27 +0000 |
| Subject: | Re: Lost data after space in PHP variables | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48968@lists.php.net to get a copy of this message | ||
On 17 February 2015 at 20:36, Charlie Lewis <charlie.lewis@honest-it.com>
wrote:
> I'm not sure that this is entirely the group for my question, so apologise
> if it is.
>
>
>
> I'm losing data in variables that use the assignment of $_POST[]. Any
> variable with a space in the $_POST[] loses everything after the space. Is
> it that I need to enclose the data with ' or "? I've tried all that with
> little success.
>
>
Using a simple script like this ...
<html>
<head>
<title>Testing spaces in names</title>
</head>
<body>
<form method="POST" action="<?= $_SERVER['PHP_SELF'] ?>?a
b=c d">
<input type="input" name="e f" value="g h">
<input type="submit">
</form>
<pre><?php
var_export($_GET);
var_export($_POST);
?></pre>
</body>
</html>
results in ...
array (
'a_b' => 'c d',
)array (
'e_f' => 'g h',
)
So, your spaces are automatically converted to _ by PHP.
This is documented at
http://php.net/manual/en/language.variables.external.php
--
Richard Quadling