Jump to content

Understanding how to use eval


george

Recommended Posts

How can I save a little PHP code to $Tom, and then evaluate $Tom and save that to a variable as attempted below:?

$Tom = "echo 'blah'"eval($Tom);

When I try and use eval here, I get the following error:

Parse error: syntax error, unexpected $end, expecting ',' or ';'

 

Worse still, I want to save the result of eval to an array element.

 

as for saving the value to an array, I tried

$bob = eval($Tom);and array_push($myarray, $varone, "'".eval($Tom)."'") 

Didn't work.

I am very frustrated with eval.

How can I do what I am trying to do?

That is, save the result of eval to an array element?

 

I did a search on eval, and got a lot of suggestions and saw lots of requests for a replacement function, but the suggestions were what I have seen before, and did not know how to apply, and the requests for a replacement function went unanswered.

 

Thanks

You guys are great.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...