You are here: Re: eval() « PHP Language « IT news, forums, messages
Re: eval()

Posted by rog on 02/27/07 00:22

Hello Matt,
Excuse me, but that's the weirdest looking PHP syntax I've ever seen!
How do you know that???
I use the { } occasionally and was looking for it in the PHP docs to see if
I could use it here. I can't find it in the docs at all. Is {} an
operator?
Anyway...Thanks!!
Roger


"shimmyshack" <matt.farey@gmail.com> wrote in message
news:1172523882.320703.317550@8g2000cwh.googlegroups.com...
> On 26 Feb, 20:55, "rog" <jk!ttop5@mnpX$.net> wrote:
>> Sorry, that should read:
>>
>> for($x=1;$x<=3;$x++)
>> {
>> $str='$unit' . $x
>> echo eval($str);
>>
>> }
>>
>> Still doesn't work.
>>
>> Roger
>>
>> "rog" <jk!ttop5@mnpX$.net> wrote in message
>>
>> news:b56dnVxMKbsi1X7YnZ2dnUVZ_vmqnZ2d@comcast.com...
>>
>> >I have some variables, $unit1, $unit2 and $unit3, that I would like to
>> >read from a loop like this (or any other way):
>>
>> > for($x=1;$x<=3;$x++)
>> > {
>> > $str='unit' . $x
>> > echo eval($str);
>> > }
>>
>> > The debugger shows $str as '$unit1' but eval() gives a parse error.
>> > Can someone give a tip?
>>
>> > Thanks,
>> > Roger
>
> you could do this:
>
> <?php
> $unit1 = '123';
> $unit2 = '231';
> $unit3 = '321';
>
> for($x=1;$x<=3;$x++)
> {
> echo ${'unit' . $x} . "\n<br />";
> }
> ?>
>

 

Navigation:

[Reply to this 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

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