PHP Classes
elePHPant
Icontem

Evaluate: Extend the eval function to allow non-php content

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2014-07-27 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 890 This week: 1All time: 3,735 This week: 1,131Up
Version License Categories  
evaluate 1.0FreewareUtilities and Tools, Text processing
Description Author  

The evaluate class extends the eval function to add the capability of mixing HTML and PHP.

The class can handle <?php //code// ?> within a text string which makes it possible to include HTML files.

Picture of Thomas Björk
Name: Thomas Björk <contact>
Classes: 11 packages by
Country: Sweden Sweden
Age: 47
All time rank: 1661 in Sweden Sweden
Week rank: 127 Up2 in Sweden Sweden Down
Innovation award
Innovation award
Nominee: 3x

Details provided by the author  
Evaluate class

The evaluate class is built on the capabilities of output buffering introduced in PHP4.
Normally the output from eval is sent to the client but with this class it is captured and made available for further processing. Otherwise everything is just like eval, well almost :-)

string function streval($code);
The ob_start function initializes the buffering and buffers all output to the client (except for headers). When the processing is done the ob_get_clean() collects the buffer and shuts it down. The result is then returned as a result from the streval function.

The argument $code contains pure php and will (most likely) fail if an attempt is made to process non-php code.


string function mixeval($str);
The argument $str contains a mix of enclosed php and non-php code. An attempt to pass pure php code to the function will fail since it require all php code to be enclosed with <?php ?> or <? ?>
The mixeval function is the same as calling streval directly with "?>" prepended to the codestring.

string function mixevalfile($filename);
Reads a file and evaluates it. Pretty much like include but with the output in a variable instead.

Thanks to Thiemo Mättig for improving the mixeval function.
  Files folder image Files  
File Role Description
Plain text file evaluate.php Class The main class
Accessible without login Plain text file example.php Example A simple exampl
Accessible without login Plain text file README.md Data Updated readme in markdown
Accessible without login Plain text file readme.txt Doc. A quick and dirty readme

 Version Control Unique User Downloads Download Rankings  
 75%Total:890All time:3,735
 This week:1This week:1,131Up