note 48378 deleted from function.eval by peehaa

From: Date: Mon, 09 Dec 2013 12:01:21 +0000
Subject: note 48378 deleted from function.eval by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197879@lists.php.net to get a copy of this message
Note Submitter: arnico at c4 dot lv ---- Dynamically loading php pages! In michael example ( 02-Sep-2004 05:16) is one big problem. Try to load php page with this content : ----------------------- <?php $a = 1; if($a == 1){ ?> <br />ir?<br /> <?php } ?> ------------------------ Ups? :) maybe easier way is to do something like that ? please comments : <?php function eval_html($string) { $string = preg_replace("/\?>(.*?)(<\?php|<\?)/si", "echo \"\\1\";",$string); $string = str_replace("<?php", "", $string); $string = str_replace("?>", "", $string); return eval($string); } $filename = "page.php"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); echo eval_html($contents); ?> The html source will be replaced with echo. and problem is gone :) or there are other problems ? please comments. P.S. sorry about my bad English

« previous php.notes (#197879) next »