Re: PHP code will not work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 13, 2008 at 1:51 PM, PJ <af.gourmet@xxxxxxxxxxxx> wrote:
>
> I had a similar problem and this was suggested and it worked for me:
>
> Try to put the global $_SERVER['HTTP_USER_AGENT'] into {}brackets:
>
> echo '{$_SERVER['HTTP_USER_AGENT']}';
>
> I'm not sure about the single quotes in your situation... I'm new at this
> too :)

    There actually two problems with that.

    First, single-quotes force everything inside to be taken
literally, as opposed to double quotes performing translation.  This
means, with single quotes, the expression won't even be evaluated
between the brackets, but you'd get this response:

        {$_SERVER['HTTP_USER_AGENT']}

     .... that is, if not for the second part.  Since you're using
single (literal) quotes, PHP will come back with a parse error based
on syntax, because of the $_SERVER array element name being included
in single quotes.  If you wanted to echo the actual name on purpose,
you can transpose quotes; place the literal (single) quotes on the
outside, and use translating (double) quotes within the brackets of
the $_SERVER superglobal array brackets.

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux