Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #11197

Re: pass variable in php construct

Path csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Date Fri, 04 Feb 2011 17:29:37 +0100
From Luuk <Luuk@invalid.lan>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en_US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version 1.0
Newsgroups comp.lang.php
Subject Re: pass variable in php construct
References <6af4aa93-3f68-4afd-a0a0-a19e021cc829@k16g2000vbq.googlegroups.com> <iidie7$3q9$1@news.eternal-september.org> <ag7ok6di260i097e9131ctlvq0kc0pgsqg@mfesser.de>
In-Reply-To <ag7ok6di260i097e9131ctlvq0kc0pgsqg@mfesser.de>
X-Enigmail-Version 1.1.1
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
Message-ID <e4mt18-ms9.ln1@luuk.invalid.lan> (permalink)
Lines 38
NNTP-Posting-Host 80.101.116.74
X-Trace 1296836974 news.xs4all.nl 81474 [::ffff:80.101.116.74]:36439
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.php:11197

Show key headers only | View raw


On 04-02-11 16:42, Michael Fesser wrote:
> .oO(Curtis Dyer)
> 
>> Joe <juliani.moon@gmail.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

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: pass variable in php construct Michael Fesser <netizen@gmx.de> - 2011-02-04 16:42 +0100
  Re: pass variable in php construct sheldonlg <sheldonlg@thevillages.net> - 2011-02-04 17:17 -0500
  Re: pass variable in php construct Curtis Dyer <dyer85@gmail.com> - 2011-02-04 22:11 +0000
  Re: pass variable in php construct Luuk <Luuk@invalid.lan> - 2011-02-04 17:29 +0100

csiph-web