As far as I know this is expected behavior. Multiple dimensional arrays will cause a parse error no matter how you do them if encapsulated inside a string. You would have to concatenate the values like so. $str = "This is a test, the value is " . $array["field"][0] . ". I repeat this is a test."; My general rule of thumb, is if it is a single dimension array I put it inside the string without quotes, outside of the array single or not, I always use quotes. Otherwise if I had a constant called "field" I would not get what I was expecting. -Chris -----Original Message----- From: Yasuo Ohgaki [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 20 March, 2001 8-17 pM To: [EMAIL PROTECTED] Subject: [PHP-DEV] PHP parser behavior. I didn't get responses for post in php-general, php-lang..... I noticed that PHP4.0.4pl1 under Linux/Apache DSO and PHP4.0.5-RC1 under W2K/IIS5 CGI accepts and does not raise error (notice messages) for following code. $arr = array('first' => 'one'); $str = "This is first element of array: $arr[first]"; // Without quotations Question: Is this expected behavior that PHP parse w/o errors? If this is NOT a expected behavior or subject to change.. I would like to know, since I'll handle all error messages for production system including notice messages. Thank you. PS: $str = "This is first element of array: $arr['first']"; // I prefer this syntax, but this line cause parse error. Using {} may be the best way to work with assoc arrays in strings, but $arr[first] is a bit easier to read than {$arr['first']}. -- Yasuo Ohgaki -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to