|
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]
|