Posted by tihu on 05/05/06 21:16
ImOk wrote:
> I come from the Visual Foxpro world, which is one reason I love PHP.
> VFP is a scripting type language with macro substitution abilities
> similar to PHP.
>
> Besides the regular expansion I can do crazy things (VFP uses & instead
> of $):
>
> x="sales"
> sales="1000"
> salestax="8.25"
> ? &x
> .........prints 1000
> ? &x.tax
> ...........prints 8.25
Just noticed the &$.tax thingy, neat trick..
In php you need to use the dot operator( joins two strings together)
and curly braces ( Think of it like php interprets the contents of {}
as an expression)
http://uk.php.net/manual/en/language.types.string.php#language.types.string.syntax.complex
$x = 'sales'
$sales = 1000;
$salestax = 8.25;
echo $$x; //prints 1000
echo ${$x.'tax'}; //prints 8.25
but
echo $$x.'tax'; // without {} it prints 1000tax
Tim
Navigation:
[Reply to this message]
|