|
Posted by Jan Pieter Kunst on 12/18/05 12:29
In article <do39vc$qdb$1@phys-news4.kolumbus.fi>, "Kimmo Laine"
<antaatulla.sikanautaa@gmail.com.NOSPAM.invalid> wrote:
> "yawnmoth" <terra1024@yahoo.com> kirjoitti
> viestissä:1134887049.415099.281110@f14g2000cwb.googlegroups.com...
> > Say I have the following script - test.php:
> >
> > <?
> > if (count($_GET) != 0)
> > {
> > foreach(array_keys($_GET) as $var)
> > {
> > echo "$var<br />";
> > }
> > }
> > ?>
> >
> > Is it possible for $var to contain a space? If I call "test.php?this
> > is=a test" it gets turned into "test.php?this%20is=a%20test" by the
> > browser and the output of the above is "this_is" - not "this is". If I
> > call "test.php?this+is=a+test", the output is still "this_is".
> >
> > I'm gonna guess it isn't possible - I just want to make sure.
>
>
> It's mentioned in the php manual that: "A valid variable name starts with a
> letter or underscore, followed by any number of letters, numbers, or
> underscores." - so no, it's not possible, as space is not either number,
> letter nor an underscroe.
But the question is not about variable names, but about the content of
variables. And array keys can certainly contain spaces. It's the
automatic urlencoding by the browser that messes things up here. Try
playing around with urldecode(), for instance:
echo urldecode($var) . '<br />';
(untested).
JP
Navigation:
[Reply to this message]
|