note 21602 added to function.eval

From: Date: Mon, 20 May 2002 23:22:43 +0000
Subject: note 21602 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-30818@lists.php.net to get a copy of this message
I don't get the !=/!== difference, they are the same I think. But if you've got the long-style PHP tags beginning with '<?php ' instead of just '<?' that function will need to offset 5 chars from the beginning, not 2: function evalHTML ( $string ) { $pos = 0; /* Loop through to find the php code in html... */ while ( ($pos = strpos( $string, '<?php' )) != FALSE ) { /* Find the end of the php code.. */ $pos2 = strpos( $string, '?>', $pos + 5); /* Eval outputs directly to the buffer. Catch / Clean it */ ob_start(); eval( substr( $string, $pos + 5, $pos2 - $pos - 5) ); $value = ob_get_contents(); ob_end_clean(); /* Grab that chunk! */ $string = substr( $string, 0, $pos ) . $value . substr( $string, $pos2 + 5); } return $string; } -- http://www.php.net/manual/en/function.eval.php http://master.php.net/manage/user-notes.php?action=edit+21602 http://master.php.net/manage/user-notes.php?action=delete+21602 http://master.php.net/manage/user-notes.php?action=reject+21602

« previous php.notes (#30818) next »