FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » pass variable in php construct
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: pass variable in php construct [message #172215 is a reply to message #172214] Fri, 04 February 2011 16:29 Go to previous messageGo to previous message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma:
Senior Member
On 04-02-11 16:42, Michael Fesser wrote:
> .oO(Curtis Dyer)
>
>> Joe <juliani(dot)moon(at)gmail(dot)com> wrote:
>>
>>> I have these simple lines in my php script:
>>>
>>> <?php
>>> if (!empty($_GET[req])) {
>>
>> You need quotes around ``req''.
>
> Yes.
>
>>> print "<h2>$_GET[req]</h2>";
>>
>> Here, too.
>
> No. Note the double quotes around the string. Quotes around the array
> key are not allowed here, unless you use curly syntax. So both of these
> ways are correct:
>
> print "<h2>$_GET[req]</h2>";
confusing syntax this is.....

But it works, and even better:
print "<h2>$_GET['req']</h2>"; <== produces an error
(PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING)


> print "<h2>{$_GET['req']}</h2>";
>
> Micha


--
Luuk
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help with my website
Next Topic: validating / converting time for insertion into mysql DB??
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 11:41:21 GMT 2024

Total time taken to generate the page: 0.04065 seconds