Skip to content

Instantly share code, notes, and snippets.

@ebernhardson
Last active August 29, 2015 14:23
Show Gist options
  • Save ebernhardson/ca4ac13859610ae6b4f6 to your computer and use it in GitHub Desktop.
Save ebernhardson/ca4ac13859610ae6b4f6 to your computer and use it in GitHub Desktop.
When running reproduce.php both eval'd pieces of code output "first", but the second one should be outputting "second"
return function ($in, $debugopt = 1) {
return (function() {return 'first';})();
};
<?php
function processTemplate( $templateName ) {
$code = file_get_contents( __DIR__ . "/$templateName.php" );
echo $code, "\n\n";
$template = eval( $code );
return $template( array() );
}
echo processTemplate( 'first' );
echo "\n-----\n\n";
echo processTemplate( 'second' );
return function ($in, $debugopt = 1) {
return (function() {return 'second';})();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment