tags:

views:

263

answers:

2

I want to know if there's a way to print an undefined variable in the body of a node, with PHP input filter, something like:

<?php
print $foo;
?>

And then, in another node define the values of the variables in the body, like:

<?php
$foo = 'bar';
?>

and embed the previous node in it with PHP or other method and print in it the variables defined in the including node.

+1  A: 

Putting php code in node body fields is never the answer.

googletorp
+1  A: 

The php filter processes the code by calling drupal_eval(), a wrapper around the standard php eval() function. From the linked documentation:

Using this wrapper also ensures that the PHP code which is evaluated can not overwrite any variables in the calling code, unlike a regular eval() call.

So your attempt would not work - and I strongly agree with googletorp that this would be a bad idea anyways.

Henrik Opel
Indeed, a good answer might be investigating the creation of your own input filter (http://api.drupal.org/api/function/hook_filter/6).
Grayside

related questions