You are here

function rabbit_hole_eval in Rabbit Hole 7.2

Evaluates php code and passes the $entity object into it.

This is a simple call to eval() wrapped in a function to prevent the user from overwriting variables. We don't want to use output buffering to capture the printed values from the code, since we're only interested in the return value.

Parameters

string $code: The PHP code that should get evaluated.

object $entity: The entity object.

Return value

mixed The return value from the evaluation.

1 call to rabbit_hole_eval()
rabbit_hole_execute in ./rabbit_hole.module
Determines the action that should be executed.

File

./rabbit_hole.module, line 404
Main module file for Rabbit Hole.

Code

function rabbit_hole_eval($code, $entity) {

  // Remove the opening and closure tags before evaluating.
  $code = trim(str_replace(array(
    '<?php',
    '?>',
  ), '', $code));
  return eval($code);
}