note 22314 added to function.eval

From: Date: Thu, 13 Jun 2002 15:26:31 +0000
Subject: note 22314 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-31805@lists.php.net to get a copy of this message
/*////////////////////////////////////////////////////////// // 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! } -- http://www.php.net/manual/en/function.eval.php http://master.php.net/manage/user-notes.php?action=edit+22314 http://master.php.net/manage/user-notes.php?action=delete+22314 http://master.php.net/manage/user-notes.php?action=reject+22314

« previous php.notes (#31805) next »