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 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> In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: 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 On 04-02-11 16:42, Michael Fesser wrote: > .oO(Curtis Dyer) > >> Joe wrote: >> >>> I have these simple lines in my php script: >>> >>> >> if (!empty($_GET[req])) { >> >> You need quotes around ``req''. > > Yes. > >>> print "

$_GET[req]

"; >> >> 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 "

$_GET[req]

"; confusing syntax this is..... But it works, and even better: print "

$_GET['req']

"; <== produces an error (PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING) > print "

{$_GET['req']}

"; > > Micha -- Luuk