RE: [PHP] echo and Session Variables
| From: | Johnson, Kirk | Date: | Fri, 22 Mar 2002 00:25:58 +0000 |
| Subject: | RE: [PHP] echo and Session Variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-89621@lists.php.net to get a copy of this message | ||
Please note that an unquoted array key is now deprecated syntax. See
http://www.php.net/manual/en/language.types.array.php
Kirk
> The single quotes in $_SESSION['myvar'] are not necessary. You're
> reading an associative array in which a string is acting as a
> pointer to
> the index.
>
> Example..
> $myarray = array ('myvar' => 'myvalue');
> echo $myarray[myvar]; // prints out 'myvalue'
> -Kevin
>
> -----Original Message-----
> From: David Johansen [mailto:daveisfera@yahoo.com]
> Sent: Thursday, March 21, 2002 4:26 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] echo and Session Variables
>
> Thanks that fixed the problem, but I have a question then. Am
> I supposed
> to
> put the ' in the $_SESSION[] in the normal parts of code. Thanks,
> Dave
>
> "Miguel Cruz" <mnc@stoic.net> wrote in message
> news:Pine.LNX.4.44.0203211648020.7613-100000@stoic.net...
> > On Thu, 21 Mar 2002, David Johansen wrote:
> > > I was just wondering if there's a way to use echo with session
> variables.
> > > When I try to do this:
> > >
> > > <?php
> > > if (isset($_SESSION['x_Email']))
> > > echo "value=\"$_SESSION['x_Email']\"";
> > > ?>
> >
> > The issue is with the syntax you're using to refer to arrays within
> double
> > quotes.
> >
> > echo "value=\"{$_SESSION[x_Email]}\"";
> >
> > miguel