Doc #53254 [NEW]: Strings variable parsing - misplaced examples

From: Date: Sun, 07 Nov 2010 18:14:09 +0000
Subject: Doc #53254 [NEW]: Strings variable parsing - misplaced examples
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5497@lists.php.net to get a copy of this message
From: Operating system: PHP version: Irrelevant Package: Documentation problem Bug Type: Documentation Problem Bug description:Strings variable parsing - misplaced examples Description: ------------ Strings variables parsing, documented on http://ca2.php.net/manual/en/language.types.string.php#language.types.string.parsing , has two forms: the simple and the complex syntax. Examples for each syntax are given, but some complex examples are in the simple section: <?php // These examples are specific to using arrays inside of strings. // When outside of a string, always quote array string keys and do not use // {braces}. // Show all errors error_reporting(E_ALL); $fruits = array('strawberry' => 'red', 'banana' => 'yellow'); // Works, but note that this works differently outside a string echo "A banana is $fruits[banana]."; // Works echo "A banana is {$fruits['banana']}."; // Works, but PHP looks for a constant named banana first, as described below. echo "A banana is {$fruits[banana]}."; // Won't work, use braces. This results in a parse error. echo "A banana is $fruits['banana']."; // Works echo "A banana is " . $fruits['banana'] . "."; // Works echo "This square is $square->width meters broad."; // Won't work. For a solution, see the complex syntax. echo "This square is $square->width00 centimeters broad."; ?> The examples of {$fruits['banana']} and {$fruits[banana]} (inside curly braces) already have equivalents in the complex syntax section. -- Edit bug report at http://bugs.php.net/bug.php?id=53254&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53254&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53254&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53254&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53254&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53254&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53254&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53254&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53254&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53254&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53254&r=support Expected behavior: http://bugs.php.net/fix.php?id=53254&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53254&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53254&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53254&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53254&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53254&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53254&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53254&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53254&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53254&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53254&r=mysqlcfg

« previous php.doc.bugs (#5497) next »