PHP_Evaluator

Executes inline PHP code during the rendering process.

Defined (1)

The class is defined in the following location(s).

/lib/dompdf/include/php_evaluator.cls.php  
  1. class PHP_Evaluator { 
  2.  
  3. /** 
  4. * @var Canvas 
  5. */ 
  6. protected $_canvas; 
  7.  
  8. function __construct(Canvas $canvas) { 
  9. $this->_canvas = $canvas; 
  10.  
  11. function evaluate($code, $vars = array()) { 
  12. if ( !$this->_canvas->get_dompdf()->get_option("enable_php") ) { 
  13. return; 
  14.  
  15. // Set up some variables for the inline code 
  16. $pdf = $this->_canvas; 
  17. $PAGE_NUM = $pdf->get_page_number(); 
  18. $PAGE_COUNT = $pdf->get_page_count(); 
  19.  
  20. // Override those variables if passed in 
  21. foreach ($vars as $k => $v) { 
  22. $$k = $v; 
  23.  
  24. //$code = html_entity_decode($code); // @todo uncomment this when tested 
  25. eval($code);  
  26.  
  27. function render(Frame $frame) { 
  28. $this->evaluate($frame->get_node()->nodeValue);