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 #172219 is a reply to message #172215] Fri, 04 February 2011 22:17 Go to previous messageGo to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma:
Senior Member
On 2/4/2011 11:29 AM, Luuk wrote:
> 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
>
>

I prefer:
print "<h2>" . $_GET['req'] . "</h2>";

No confusion thee.



--
Shelly
[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: Sun Nov 10 11:18:14 GMT 2024

Total time taken to generate the page: 0.05241 seconds