note 48378 added to function.eval

From: Date: Tue, 21 Dec 2004 11:28:52 +0000
Subject: note 48378 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-82125@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48378 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48378&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48378&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48378&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48378&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48378&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48378&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48378&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82125) next »