Tuesday, March 10, 2009

Interpreted Language Hack

This is done in PHP but it would work in any language that isn't compiled

I had a string containing PHP code which i wanted executing(evaluating).

A few years ago i did a project where i needed to do this and there was a PHP function to do this but I combed www.php.net for about an hour with no success.

Simply i take the string put it in a file then include said file like a library.

<?php
$value = "" ;
file_put_contents ( 'temp.php' , $value );
include('temp.php');
?>

You shouldn't use this on a online server as it opens up the possibility of code injection but i use PHP in offline system and shell scripts.

2 comments:

DjC said...

Thanks to Mr Slater http://uk3.php.net/eval

Umair Ali said...

A language is interpreted with the support of the translator of the languages for the individuals. The participation of the man to visit http://best-essay-writing-service.reviews/worst-services/ has been explored for the use of the translator for all purposes for the books and articles in different languages.