RE: [PHP] Parse error: parse error, expecting `']'' in

From: Date: Thu, 02 Dec 2004 13:24:46 +0000
Subject: RE: [PHP] Parse error: parse error, expecting `']'' in
Groups: php.general 
Request: Send a blank email to php-general+get-203338@lists.php.net to get a copy of this message
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 01 December 2004 19:29, Matthew Sims wrote: > > So when using arrays with string keys within strings you need to > concatenate it. > > $var = "I live in the city of ". $_POST['cityname']; No, you do not *need* to -- it is one option, certainly, but there is no necessity about it. Within double-quoted strings, it is perfectly acceptable to use unquoted array keys: $var = "I live in the city of $_POST[cityname]"; If you prefer to quote your keys, or have more complex expressions within the brackets, there is also the {} syntax: $var = "I live in the city of {$_POST['cityname']}"; $field = 'city'; $var = "I live in the $field of {$_POST[$field.'name']}"; Anyway, read up on it. http://uk.php.net/manual/en/language.types.string.php#language.types.string. parsing Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#203338) next »