Reputation: 49703
Say I have a variable containing PHP code, can I include its content as if it was a normal PHP file ?
For example, the PHP code could be a class declaration.
Upvotes: 0
Views: 301
Reputation: 14951
You don't have a variable containing php code. You have a string. You can execute a string as php with the evil eval function, but puppies AND kittens will die!
Upvotes: 8
Reputation: 12618
You could use eval
to evaluate any code that you have in your string, however it is evil. What exactly are you trying to do?
Upvotes: 4
Reputation: 50982
eval($your_variable);
Be aware about security holes!This is very dangerous and should NOT be based on user's input !
Upvotes: 7