On Mon, 2002-02-18 at 15:02, Erik Price wrote:
>
> On Monday, February 18, 2002, at 05:50 PM, Narvaez, Teresa wrote:
>
> > When I execute the code below, why is PHP_SELF undefined? I will
> > appretiate
> > any help on this. I can get its value by:
> > echo $_SERVER["PHP_SELF"]; Thanks in advance! -Teresa
> >
> >
> > <HTML>
> > <HEAD>
> > <TITLE>Feedback</TITLE>
> > </HEAD>
> > <BODY>
> > <?
> > $form_block = "
> > <FORM method=\"POST\" action=\"$PHP_SELF\">
> ^^^^^^^^^
>
> It hasn't been pulled from the $_SERVER array. It worked for you when
> you did it the first way, so try doing it that same way in the code:
>
> <form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">
>
> Note that I had to "jump out" of the string and concatenate it to the
> variable, because PHP doesn't let you just use $_* variables in the
> middle of a string. I also made sure to "jump back into" the string to
> finish the HTML form tag.
Sorry, but I do have to correct you here--this isn't true. ;) In double-
quoted strings and heredocs, you can do the following:
$foo = "This page is $_SERVER[PHP_SELF]";
Or, better:
$foo = "This page is {$_SERVER['PHP_SELF']}";
You do have to concat to do this in single-quoted (noninterpolated)
strings, though.
http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing
Cheers,
Torben
> If you don't like doing it this way, do something like
>
> $PHP_SELF = $_SERVER['PHP_SELF'];
> $form_block = "<form method=\"post\" action=\"$PHP_SELF\">";
>
>
> HTH
>
> Erik
--
Torben Wilson <[EMAIL PROTECTED]>
http://www.thebuttlesschaps.com
http://www.hybrid17.com
http://www.inflatableeye.com
+1.604.709.0506
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php