PHP Classes

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

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (8 months ago) RSS 2.0 feedStarStarStar 42%Total: 911 All time: 3,898 This week: 66Up
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
Age: 56
All time rank: 1581 in Sweden Sweden
Week rank: 163 Down2 in Sweden Sweden Down
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 (4)  
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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 75%
Total:911
This week:0
All time:3,898
This week:66Up
 User Ratings  
 
 All time
Utility:45%StarStarStar
Consistency:60%StarStarStarStar
Documentation:70%StarStarStarStar
Examples:65%StarStarStarStar
Tests:-
Videos:-
Overall:42%StarStarStar
Rank:3667