One thing to note is that constants are not looked for within strings. So:
// This is okay but can cause confusion. No errors // are created but many prefer not to do this. $str = "Hello $there[friend], how are you?"; Outside of a string, $there[friend] will indeed seek a constant named friend first: // This is not okay but may or may not work as expected // and will create an error of level E_NOTICE if the // constant friend does not exist. So don't do this. $str = $there[friend]; The preferred methods are as follows: // Use of {} here won't work in PHP3 (iirc) $str = "Hello {$there['friend']}, how are you?"; // Concatenation is always a possability $str = 'Hello ' . $there['friend'] . ', how are you?'; Related resources: http://www.php.net/en/language.types.string.php http://www.zend.com/zend/tut/using-strings.php Regards, Philip Olson On Thu, 2 May 2002, Dan Hardiker wrote: > Hi, > > > I would suggest not to use $hash[var1][var2] instead of > > $hash['var1']['var2'] because afaik php will think u mean two constants > > ( var1 and var2 ). > > Just if it doesnt find these constants it will use them as > > $hash['var1']['var2']. > > Thats correct, php will think they are constants and upon not finding them > will send up a low priority error (I think its of E_NOTICE). Appologies for > sloppy coding (must remember to be more awake). > > $hash['var1']['var2'] is much better, safer, more compatable and faster > (marginally - as it doesnt have to check for constants of that name). As an > extra note, (and this of personal desire rather than coding standards), I > would always break out of a string to insert variables. Personally it just > highlights the dynamic parts of string creation. > > eg: = "Name: ".$user->name." is age ".$user->age.". ".(($user- > >birthday==$today)?"Happy Birthday!")."<br />"; > > but thats getting out of the scope of the question heh > > -- > Dan Hardiker [[EMAIL PROTECTED]] > ADAM Software & Systems Engineer > First Creative Ltd > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php