tags:

views:

32

answers:

1

Hello,

I need to pass a return $variable; within the eval function, which in turn is going to return a value for a function.

Here is an example:


function something()
{
$sSomeVar = 'something';
eval( 'return $sSomeVar = 3;' );
}

The code above will return 3 for the eval, but the function will not return the value for the variable.

So does anyone know how to return a return within an eval?

+3  A: 

This should do the trick:

function something() 
{
  $sSomeVar = 'something';
  return eval( 'return $sSomeVar = 3;' );
}
Dennis Haarbrink
I cannot recode the the function. So that solution is not available.
Ryan