|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I don't understand why this expression doesn't work:
$var= '$_POST'; $name= ${$var}[name]; the ${$var}[name] expression wont return the same expression of $_POST[name]. why does it happens, and how can i solve it? thanks |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Sep 15, 10:32 am, Gandalf <goldn...@gmail.com> wrote:
> I don't understand why this expression doesn't work: > > $var= '$_POST'; > > $name= ${$var}[name]; > > the ${$var}[name] expression wont return the same expression of > $_POST[name]. > why does it happens, and how can i solve it? > > thanks i meant to write $var ='_POST', and the that ${$var}[name] wont return the same value as $_POST[name] |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Gandalf wrote:
> On Sep 15, 10:32 am, Gandalf <goldn...@gmail.com> wrote: >> I don't understand why this expression doesn't work: >> >> $var= '$_POST'; >> >> $name= ${$var}[name]; >> >> the ${$var}[name] expression wont return the same expression of >> $_POST[name]. >> why does it happens, and how can i solve it? >> >> thanks > > i meant to write $var ='_POST', > and the that ${$var}[name] wont return the same value as $_POST[name] > hi this should work as expected. Care to post more code? -- gosha bine extended php parser ~ http://code.google.com/p/pihipi blok ~ http://www.tagarga.com/blok |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Sep 15, 11:07 am, gosha bine <stereof...@gmail.com> wrote:
> Gandalf wrote: > > On Sep 15, 10:32 am, Gandalf <goldn...@gmail.com> wrote: > >> I don't understand why this expression doesn't work: > > >> $var= '$_POST'; > > >> $name= ${$var}[name]; > > >> the ${$var}[name] expression wont return the same expression of > >> $_POST[name]. > >> why does it happens, and how can i solve it? > > >> thanks > > > i meant to write $var ='_POST', > > and the that ${$var}[name] wont return the same value as $_POST[name] > > hi > > this should work as expected. Care to post more code? > > -- > gosha bine > > extended php parser ~http://code.google.com/p/pihipi > blok ~http://www.tagarga.com/blok $var gets the value '_POST' function create_par($var){ global $_, $_POST, $active; if(${$var}[no_win_from]!=0 || ${$var}[no_win_to]!=${$var}[games]) $active[0]="no_win"; else die(${$var}[games]); if(${$var}[out_win_from]!=0 || ${$var}[out_win_to]!=${$var}[games]) $active[1]="out_win"; if(${$var}[yedaActive_2]=="true"){ if(${$var}[range_yeda1_from]!=0 || ${$var}[range_yeda1_to]!=${$var} [games])$active[2]="range_yeda1"; } if(${$var}[yedaActive_3]=="true"){ if(${$var}[range_yeda2_from]!=0 || ${$var}[range_yeda2_to]!=${$var} [games]) $active[3]="range_yeda2"; } if(${$var}[home_win_from]!=0 || ${$var}[home_win_to]!=${$var}[games]) $active[4]="home_win"; } |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
..oO(Gandalf)
>$var gets the value '_POST' >function create_par($var){ > global $_, $_POST, $active; $_, $_POST etc. are always available, no need to use 'global' on them. But: | Please note that variable variables cannot be used with PHP's | Superglobal arrays within functions or class methods. Micha |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Michael Fesser wrote:
> | Please note that variable variables cannot be used with PHP's > | Superglobal arrays within functions or class methods. I read that, and re-read it, and re-read it... and I can't figure out what it means. Can you re-phrase it? I was good right up to "within functions...". I use super globals within functions all the time. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
..oO(Sanders Kaufman)
>Michael Fesser wrote: > >> | Please note that variable variables cannot be used with PHP's >> | Superglobal arrays within functions or class methods. > >I read that, and re-read it, and re-read it... and I can't figure out >what it means. Can you re-phrase it? > >I was good right up to "within functions...". I use super globals >within functions all the time. A variable variable is something like that: $foo = 'bar'; $bar = 42; print ${$foo}; // prints 42 This means the name of the variable is taken from another (string) variable. The same can be done with superglobals, but not if you're inside a function or method: function test() { $foo = '_GET'; var_dump(${$foo}); // throws a notice } Micha |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Michael Fesser wrote:
> A variable variable is something like that: > > $foo = 'bar'; > $bar = 42; > > print ${$foo}; // prints 42 > > This means the name of the variable is taken from another (string) > variable. The same can be done with superglobals, but not if you're > inside a function or method: > > function test() { > $foo = '_GET'; > var_dump(${$foo}); // throws a notice > } I think that what's confusing me is that double-dollar thing. I've seen it before, but thought it was a typo. Could you tell me what it means, or where to look in the docs to find out about it. |
|
![]() |
| Outils de la discussion | |
|
|