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:[EMAIL PROTECTED]]
> Sent: Thursday, March 21, 2002 4:26 PM
> To: [EMAIL PROTECTED]
> 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" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > 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
>


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

Reply via email to