note 22314 deleted from function.eval by victor

From: Date: Sat, 12 Jun 2004 22:42:25 +0000
Subject: note 22314 deleted from function.eval by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71002@lists.php.net to get a copy of this message
Note Submitter: Bart Koelman ---- /*////////////////////////////////////////////////////////// // Function: OutputPhpDocument // Description: Handles a string as if it were a .php file on disk, that // is being requested by a client browser. Normal // text will just be output, while php code between php // tags will be executed. // Arguments: $phpDocument: The string that contains data // that would normally be in a .php file on disk // Uses: (all global variables will be made available) // Returns: if the code in $phpDocument returns a value, // that value will be returned // Example: $phpDocument = { // abc <? echo " def"; ?> // <?= " ghi" ?> // } // will output: "abc def ghi" //////////////////////////////////////////////////////////*/ function OutputPhpDocument($phpDocument) { // Make global variables available (so it seems that this code is not // being called from within a function) reset ($GLOBALS); while (list ($key, $val) = each ($GLOBALS)) { eval("\$" . "\$key = \"$val\";"); } $questMark = "?"; $phpOpenTag = "<${questMark}php"; $phpCloseTag = "${questMark}>"; return eval("$phpCloseTag" . stripslashes($phpDocument) . "$phpOpenTag "); // note the trailing space! }

« previous php.notes (#71002) next »