Einzelnen Beitrag anzeigen

Benutzerbild von Airblader
Airblader

Registriert seit: 29. Okt 2004
Ort: Geislingen an der Steige
742 Beiträge
 
#10

Re: [PHP]PHP Code im String soll vor Ausgabe interpretiert w

  Alt 1. Nov 2005, 21:16
Laut einem Userkommentar auf php.net macht es doch einen unterschied zwischen <? und <?php.
Hier der Quote:

Zitat:
to load a php file to a variable then execute it, try this

Code:
<?php
$code=file_get_contents("file.php");
$code=str_replace('<'.'?php','<'.'?',$code);
$code='?'.'>'.trim($code).'<'.'?';
eval($code);
?>
using < ?php within eval does not work, but < ? does. in case there is html in the file loaded, the script doesn't remove the < ?php and ? >, but insted adds ? > and < ? around the code loaded from the file. it's simple and works very well. I also broke up the tags in the 3rd and 4th lines of code to keep from having problems if the lines are commented out.
( http://de.php.net/eval )
Ingo Bürk
Es nimmt der Augenblick, was Jahre geben.

Johann Wolfgang von Goethe
  Mit Zitat antworten Zitat