RE: [PHP] echo and Session Variables
| From: | Rasmus Lerdorf | Date: | Thu, 21 Mar 2002 23:42:11 +0000 |
| Subject: | RE: [PHP] echo and Session Variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-89612@lists.php.net to get a copy of this message | ||
Well, a stray define('myvar','foo') somewhere would make a mess of that.
It is safer to use $myarray['myvar']. Inside a quoted string you of
course shouldn't use the ''
-Rasmus
On Thu, 21 Mar 2002, Kevin Stone wrote:
> 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
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>