I get the following error:

Strict warning: Only variables should be passed by reference in include() (line 18 of /home/sites/dev/theparce/sites/all/themes/parce/block--block--3.tpl.php).

This is the block code which is causing that error.

if ($user_gallery) {
  print render(node_show($user_gallery));  // Line 18
  print drupal_render ($user_gallery_edit);

else {
  print drupal_render($user_gallery_new);

Why do I get that error, even if I get all printed as expected?

1 Answer 1


That error happens when a function is expecting a reference as parameter, but it is not getting a reference.

In your case, render() is defined as render(&$element), but node_show() is defined as node_show($node, $message = FALSE), not &node_show($node, $message = FALSE).
The same would be true for drupal_render(), since the function is defined as drupal_render(&$elements).

As explained on Passing by Reference, when a function requires a reference parameter, you can pass to the function:

  • Variables (for example, a temporary variable containing the result of a function which is not returning a reference)

  • References returned from functions

Using other expressions, the result is undefined, and it depends from the PHP version.

  • render(node_show()) produces a fatal error in PHP 5.0.5, a strict standards notice in PHP 5.1.1, and a notice in PHP 7.0.0

  • render(5) produces a fatal error

  • render(new DateTime()) produces a notice in PHP 7.0.7 (Notice: Only variables should be passed by reference)


Not the answer you're looking for? Browse other questions tagged or ask your own question.