You are here

function rules_php_eval in Rules 7.2

Same name and namespace in other branches
  1. 6 rules/modules/php.rules.inc \rules_php_eval()

Evaluates the given PHP code, with the given variables defined.

Parameters

string $code: The PHP code to run, including <?php and ?>

array $arguments: Array containing variables to be extracted to the code.

Return value

The output of the php code.

Related topics

1 call to rules_php_eval()
RulesPHPEvaluator::evaluate in modules/php.eval.inc
Evaluates PHP code contained in $text.

File

modules/php.eval.inc, line 152
Contains rules integration for the php module needed during evaluation.

Code

function rules_php_eval($code, $arguments = array()) {
  extract($arguments);
  ob_start();
  print eval('?>' . $code);
  $output = ob_get_contents();
  ob_end_clean();
  return $output;
}