> What you might try is removing the single-quotes from around PHP_SELF.
>
> Before: $_SERVER['PHP_SELF']
> After:  $_SERVER[PHP_SELF]
>
> Another note: as far as I can tell you do not need the braces ({}) to
> enclose a variable within a double-quoted string. I may be wrong, but
> nothing I've read advocates doing this, and I've never had a problem
> with my code when I've written it this way.

Just so there's no confusion, with double quoted strings, you can do it one
of two ways.

echo "The value is {$_SERVER['PHP_SELF']}";
or
echo "The value is $_SERVER[PHP_SELF]";

Neither is any more right than the other. You can always end the string and
concatinate the variable, too...

echo "The value is " . $_SERVER['PHP_SELF'];

In that case, you should always use quotes around the key, single or double,
doesn't matter much.

---John Holmes...

> > --------------------[snip]--------------------
> >
> >>Could someone tell me why this code prompts a parse error. I have tried
it
> >>several different way. The statement is called from within a function:
> >>
> >>print "<form method=\"POST\" name=\"update_workshop\"
> >>action=\"$_SERVER['PHP_SELF']\">\n";
> >
> > --------------------[snip]--------------------
> >
> > When using array elements within a string you must enclose it in curly
> > brackets, like this:
> >
> > print "<form method=\"POST\" name=\"update_workshop\"
> > action=\"{$_SERVER['PHP_SELF']}\">\n";
> >
> > HTH,
> >
>
>
> --
> 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