ID: 20601 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Windows ME PHP Version: 4.3.0RC1 Assigned To: philip New Comment:
Thanks for the report, the documentation has been updated here: http://cvs.php.net/cvs.php/phpdoc/en/language/types.xml On a related note, this may end up not being a parse error in the future. The documentation will be updated once a verdict is made on bug #21820 so hold tight :) Previous Comments: ------------------------------------------------------------------------ [2002-12-17 10:51:18] [EMAIL PROTECTED] Sort of. This is a feature I was not aware of in PHP and imho is sort of a bug :) As it turns out, constants are only seen in strings if: a) It's an array key b) {braces} are around the array So for example, NO E_NOTICE is generated from "a $arr[foo]" but "a {$arr[foo]}" does! And btw, "a {foo}" does not look for the constant foo. And because multidimensional arrays inside strings require {braces} this is an important point. IMHO this behavior of constants inside strings is inconsistent and I'm writing php-dev now! :) ------------------------------------------------------------------------ [2002-12-17 10:37:35] [EMAIL PROTECTED] Philip, please do not change that part of the documentation. **It is correct!**. Try with this script: <?php error_reporting(E_ALL); ini_set("display_errors", TRUE); $arr['foo'][3] = 14; echo "This is wrong: {$arr[foo][3]}"; echo "This is good: {$arr['foo'][3]}"; ?> For the first echo line, a NOTICE error is echoed out... So the documentation is correct. It may not be clear enough, but it is correct, the example is right. ------------------------------------------------------------------------ [2002-12-05 13:49:27] [EMAIL PROTECTED] As it turns out, the string docs are wrong and contain the following in the example: // This is wrong for the same reason // as $foo[bar] is wrong outside a string. echo "This is wrong: {$arr[foo][3]}"; I'll rewrite this part of the documention too. $foo[bar] is perfectly fine inside strings, CONSTANTS aren't seen in strings. Anyway, this will be further explained with a more specific example too. And a faq entry :) This question comes up waaaaaaay too much these days. ------------------------------------------------------------------------ [2002-12-05 13:26:22] [EMAIL PROTECTED] The string type description includes a lengthy explanation of this AFAIK. ------------------------------------------------------------------------ [2002-12-04 19:03:14] [EMAIL PROTECTED] Btw, this happens when you do: print "a foo $bar['blah'] eh"; Don't do that. You can do either: print "a foo {$bar['blah']} eh"; print "a foo $bar[blah] eh"; print "a foo " . $bar['blah'] . " eh"; But when outside of strings always quote your keys: print $bar[blah]; // bad print $bar['blah']; // good Unless of course you defined blah as a constant earlier. Anyway I'm making a faq out of this question and marking as a doc bug because this question comes up a lot especially since 4.1.0 (autoglobals) and 4.2.0 (register_globals default change). ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/20601 -- Edit this bug report at http://bugs.php.net/?id=20601&edit=1 -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
