If the code is the same, there appears to be a difference between:
include \'external.php\';
and
eval(\'?>\' . file_get_conten
After some more research I found out what was wrong myself. The problem is in the fact that is a "short opening tag" and so will only work if
short_open_tag
is set to 1 (in php.ini or something to the same effect). The correct full tag is , which has a space after the second p.
As such the proper equivalent of the include is:
eval('?>' . file_get_contents('external.php') . '
Alternatively, you can leave the opening tag out all together (as noted in the comments below):
eval('?>' . file_get_contents('external.php'));
My original solution was to add a semicolon, which also works, but looks a lot less clean if you ask me:
eval('?>' . file_get_contents('external.php') . '