| 
	
 | 
 Posted by sagejoshua on 06/17/17 11:31 
On Mon, 07 Nov 2005 13:53:53 GMT, Michael Winter 
<m.winter@blueyonder.co.uk> wrote: 
 
 
>To elaborate on what Leif wrote, the variable variable constructed above  
>  is made possible through string concatenation, similar to 
> 
>   var variable = 'foo'; 
> 
>   this[variable + 'bar'] = 'Great!';  /* foobar = 'Great!'; */ 
> 
 
Ah, it all starts to make sense now. You can refer to any variable 
using the "global array" this[whatever], and whatever is in the 
brackets will be parsed. Very nice tool. My question is, what's so 
evil about eval()? 
 
>in ECMAScript. However, rather than using a string literal, the OP has  
>written in bar what would normally considered a constant. Indeed, if  
>STRICT notices are enabled in PHP, this will be reported in the error log. 
> 
>It would be better written as: 
> 
>   <?php 
>   $variable = 'foo'; 
>   ${$variable . 'bar'} = 'Great!'; 
>   print $foobar;  /* Great! */ 
>   ?> 
 
Yeah, you're right. I was just being sloppy. 
 
 
Thanks for all the help. 
Josh
 
  
Navigation:
[Reply to this message] 
 |