PHP Classes

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

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (4 days ago) RSS 2.0 feedStarStarStar 42%Total: 908 This week: 1All time: 3,903 This week: 350Up
Version License Categories
evaluate 1.0FreewareTools, 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
  Performance   Level  
Name: Thomas Björk <contact>
Classes: 11 packages by
Country: Sweden Sweden
Innovation award
Innovation award
Nominee: 3x

Details

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:908
This week:1
All time:3,903
This week:350Up
 User Ratings  
 
 All time
Utility:43%StarStarStar
Consistency:62%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:68%StarStarStarStar
Tests:-
Videos:-
Overall:42%StarStarStar
Rank:2914