You are here: Re: Just Learning PHP « PHP Language « IT news, forums, messages
Re: Just Learning PHP

Posted by Ian Hobson on 09/07/07 22:59

macca wrote:
> Ok, thanks Ian.
>
> I did a little reading on compound variables.
>
> The problem I was'nt quite understanding is where the braces are
> needed,
>
> as the string
>
> "<a href=\"page.htm\">$var</a>";
>
> has other characters (HTML) directly after the name of the variable
> without any spaces.
>
> Does this not matter?
>
Hi Macca,

No - the parser will recognise the $ and what follows it as a variable
name, and will stop with the next character that can't be part of a
variable name (IIRC only letters, digits, and _ are allowed).

thus

$var = "fred";
$array[2] = "bill";
echo ">$var<"; // = '>fred<'

echo ">$array[2]<"; // error ($array is not convertible to a string.)

echo ">{$array[2]}<" // = '>bill<'

Regards

Ian

 

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

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