Reply to Re: Include Problem ?

Your name:

Reply:


Posted by Rik Wasmus on 10/26/07 11:18

On Fri, 26 Oct 2007 13:04:58 +0200, Captain Paralytic =

<paul_lautman@yahoo.com> wrote:
> On 26 Oct, 12:01, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>> On Fri, 26 Oct 2007 12:47:44 +0200, Captain Paralytic
>> > Surely {$content[$x]} won't work. PHP does only one substitution so=

>> > {$content[1]} will work but {$content[$x]} doesn't (at least in my
>> > experience).
>>
>> The code:
>> <?php
>> echo phpversion();
>> $foo =3D array(3 =3D> 'bar');
>> $x =3D 3;
>> echo "{$foo[$x]}";
>> ?>
>> Output:
>> 5.2.4bar
>>
>> The magic is in the braces.
>
> So would
> echo "$foo[$x]";
> not work then?

That's a whole other issue, and in this case it would work. See for a =

detailed explanation =

http://nl2.php.net/manual/en/language.types.string.php#language.types.st=
ring.parsing

Would we change it to this:
<?php
echo phpversion();
$foo =3D array(array(3 =3D> 'bar'));
$x =3D 3;
//works, outputs 'bar'
echo "{$foo[0][$x]}";
//doesn't work, outputs 'Array[3]'
echo "$foo[0][$x]"
?>

.... which is why it's a good thing to pick up the habit to use curly =

braces when using something other then a direct scalar in a string.
-- =

Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация