RE: [PHP] PHP Bug or just a strange behaivor?

2003-07-09 Thread Ford, Mike [LSS]
> -Original Message-
> From: Marcus Hufvudsson [mailto:[EMAIL PROTECTED]
> Sent: 09 July 2003 13:56
> 
> Hi, Let's get right to it...
> When I try to do this:
> 
>  echo $_COOKIE['test.1'];
> ?>
> 
> It doesn't work (needless to say there is a cookie that goes 
> by this name)
> 
> So, when I did this:
> 
>foreach($_COOKIE as $cook => $val) {
>   echo $val ." -> " .$cook ."";
>   }
> ?>
> 
> I got:
> ec1c9edd209143432f36fsd29af410ef27 -> test_1
> 
> Notice the _ (underscore) instead of . (dot)

Because, when register_globals is set to On, the names of all GET, POST and
COOKIE parameters will be used as variable names, they may only contain
characters which are legal in PHP variable names.  PHP automagically
converts all other characters to _ on the fly as they are loaded into the
$_GET, $_POST and $_COOKIE arrays and, if register_globals is set, the
equivalent global variables.

> So I though that you couldn't have dots in your array 
> names...

There's no problem with this -- it's purely that GET, POST and COOKIE names
must conform to PHP variable naming rules.

This is documented, if somewhat minimally, at
http://uk2.php.net/manual/en/language.variables.external.php#language.variab
les.external.dot-in-names.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Bug or just a strange behaivor?

2003-07-09 Thread Chris Boget
> So I though that you couldn't have dots in your array names... Just to 
> be sure I wrote a small test program like this:
[snip]
> So... anyone know what's up?

I believe that if you do it manually in a script, it works fine.  But if PHP
gets/sets the value from POST, GET, COOKIE, etc. it converts the dot
to an underscore.
Using the same test script (using donald.1), store it in a cookie and then
retrieve it.  Send it as POST or GET then try to display the value.  Really 
good odds are that the dot will be converted.  Again, I belive this is in 
the documentation, but I can't rightly remember where. :|

Chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php