Re: how call a variable in a text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





> So no they are not meant to go around. You can use them this way as well.

that has almost the same meaning of

$_ = '_POST';
echo count($$_);

which again, for readability brackets are suggested to improve maintainability

$_ = '_POST';
echo count(${$_});

Regards

------------------------------------------------------------------------
<http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009>

I don't think it is about readability:

$arr[3] = 'test';
$test = 3;

//This prints "$test"
echo "This doesn't work: $$arr[3]";

//This prints 3
echo "This works: ${$arr[3]}";

Using the same type way as before in this thread.

My point is that in the curly braces you protect the way the evaluation is going to be made into the string. So you can put them anywhere as long as it is meaningful.

See some examples:

http://php.net/manual/en/language.types.string.php

in the complex (curly) syntax section.

--
Thodoris


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux