Re: Lost data after space in PHP variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17 February 2015 at 20:36, Charlie Lewis <charlie.lewis@xxxxxxxxxxxxx>
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

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux