NYCPHP Meetup

NYPHP.org

[nycphp-talk] Quick little question - variable interpolation

David Sklar sklar at sklar.com
Thu Oct 17 17:28:30 EDT 2002


> Why explode and rejoin instead of just one eval?
> 
> $foo = eval("return '$foo';");
> 
> You might need to addslashes() on $foo first:
> 
> $safe = addslashes($foo);
> $foo  = eval("return '$safe';");

Oops, those should be doublequotes inside the eval:

$foo = eval("return \\"$foo\\";");

and

$safe = addcslashes($foo,'"');
$foo  = eval("return \\"$safe\\";");

-dave




More information about the talk mailing list