|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-05-08 04:49 UTC] mgf@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 15:00:02 2025 UTC |
There is a very strange error when using associative array naming within quotes, have a look here. This is based on the PHP5 May 5th 17:30GMT build. In PHP 4.3.1 <?php $arr = array("hello" => "hello world"); echo "$arr['hello']"; ?> The above code does not output any information. The quotes have something to do with this. <?php $arr = array("hello" => "hello world"); echo $arr['hello']; ?> This above code fragment will print "hello world". The usage that is consistent always is not using single quotes : <?php $arr = array("hello" => "hello world"); echo "$arr[hello]"; // echo $arr[hello]; executes! ?> The above is still acceptable and does not generate any error. Not even a notice if it is turned on, so it most likely an output related bug. Now coming to PHP5! <?php $arr = array("hello" => "hello world"); echo "$arr[hello]"; echo $arr[hello]; exectues! ?> The above code works fine, with and without the quotes. <?php $arr = array("hello" => "hello world"); echo "$arr['hello']"; // echo $arr['hello']; executes! ?> This code does not work if the quotes are present, works when the quotes are removed!