You are here: Re: Help understanding 3 lines of code « PHP Programming Language « IT news, forums, messages
Re: Help understanding 3 lines of code

Posted by Steve on 04/16/07 15:47

"dangerd" <duncanelliot@breathe.com> wrote in message
news:1176737155.703447.58140@n59g2000hsh.googlegroups.com...
| Hi folks,
|
| can someone help me understand the meaning behind this snippet of
| code:
|
| $result = mysql_query('SELECT category_id,category_name FROM
| gallery_category');
| while($row = mysql_fetch_array($result)) {
| $photo_category_list .= <<<__HTML_END
| <option value="$row[0]">$row[1]</option>\n
| __HTML_END;
| }
|
| I start to get confuse when the .=<<<_HTML_END bit start, how does
| this work? I don't understand.
|
| Thanks

it's called a heredoc. i hate them, but others love them. essentially you
are breaking out of php code so that what is contained inbetween <<<__TAG
and __TAG can be written as if it were literal text. it is much more clear
to me to do:

$photo_category_list .= '<option value="' . $row[0] . '">' .
$row[1] .
"</option>\n";

but that's just me.

btw, wouldn't it make much more sense to make $row be $columns since the key
of the array points to a column/field and not a row of data?

 

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

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