Rush Frisby
Rush Frisby

Reputation: 11454

Possible to execute php string?

If I have a variable that contains PHP code... something like this:

$PageCode = "<?php\r\nrequire_once(\"../code/rushs_flickr_photos.php\");\r\n?>";

Is it possible to execute that code within my page and assign it back to another variable? something like:

$PageContent = exec($PageCode);

Upvotes: 0

Views: 634

Answers (2)

Viper_Sb
Viper_Sb

Reputation: 1817

Yes look at eval() function

Upvotes: 2

NullUserException
NullUserException

Reputation: 85458

Yes. You are looking for eval().

This is however considered very bad practice. Whatever it is that you are trying to do, there is most likely a better way.

Upvotes: 9

Related Questions