# css-javascript-toolbox/6.0.15/framework/php/evaluator/evaluator.inc.php

CSS &amp; JavaScript Toolbox, version 6.0.15. 94 lines.

- Page: https://pluginprobe.com/plugins/css-javascript-toolbox/6.0.15/code/framework/php/evaluator/evaluator.inc.php
- Raw: https://pluginprobe.com/plugins/css-javascript-toolbox/6.0.15/raw/framework/php/evaluator/evaluator.inc.php
- Modified: 2013-03-17T20:09:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/css-javascript-toolbox/6.0.15/code/framework/php/evaluator/evaluator.inc.php#L10-L20`.

```php
<?php
/**
* 
*/

/**
* 
*/
class CJTPHPCodeEvaluator {
	
	/**
	* put your comment there...
	* 
	* @var mixed
	*/
	private $block = null;
	
	/**
	* put your comment there...
	* 
	* @var mixed
	*/
	private $output = null;
	
	/**
	* put your comment there...
	* 
	* @param mixed $code
	* @param stdClass Block object!
	* @return CJTPHPCodeEvaluator
	*/
	public function __construct(& $block) {
		// Hold Block code!
		$this->block = $block;
	}
	
	/**
	* put your comment there...
	* 
	* @param mixed $stack
	*/
	public function exec($stack = array()) {
		$block =& $this->block;
		$code =& $block->code;
		// Make all stack variables available to the local scope.
		extract($stack);
		// Evaluate PHP codes!
		ob_start();
		// Evaluate PHP code and save the result!
		$beforeEvalError = error_get_last();
		$unusedResult = eval("?>{$code}");
		$evalOBuffer = ob_get_clean();
		// Handling errors!
		if ($beforeEvalError != error_get_last()) {
			if (ini_get('display_errors')) {
				$this->output  = 'CJT PHP Code Error detected for the following block: <br><br>';
				$this->output .= "Name: {$block->name}<br>";
				$this->output .= "ID: #{$block->id}<br><br>";
				$this->output .= "PHP Error Details are listed below:<br>";
				$this->output .= $evalOBuffer;
			}
		}
		else { // Get evaludated code result!
			$this->output .= $evalOBuffer;
		}
		return $this;
	}
	
	/**
	* put your comment there...
	* 
	*/
	public function getBlock() {
		return $this->block;	
	}
	
	/**
	* put your comment there...
	* 
	* @param mixed $code
	*/
	public static function getInstance($code) {
		return new CJTPHPCodeEvaluator($code);
	}
	
	/**
	* put your comment there...
	* 
	*/
	public function getOutput() {
		return $this->output;
	}
} // End class.

```
