$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>PHP Strict Standards: Only variables should be assigned by reference|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

PHP Strict Standards: Only variables should be assigned by reference

matteradmin8PV0评论

Here's the code in question. It started looking like this:

$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));  
return count($comments_by_type['comment']);

I removed the & signs per other posts I have seen but it didn't help.

$comments_by_type = separate_comments(get_comments('status=approve post_id=' . $id));
return count($comments_by_type['comment']);

Here's the code in question. It started looking like this:

$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));  
return count($comments_by_type['comment']);

I removed the & signs per other posts I have seen but it didn't help.

$comments_by_type = separate_comments(get_comments('status=approve post_id=' . $id));
return count($comments_by_type['comment']);
Share Improve this question edited Nov 1, 2018 at 18:42 Will B. 1136 bronze badges asked Nov 1, 2018 at 16:56 MBensonMBenson 11 silver badge2 bronze badges 3
  • the arguments for separate_comments are being passed by-reference as function separate_comments(&$comments). You would need to assign get_comments to a variable. $comments = get_comments('status=approve&post_id=' . $id); Then separate_comments($comments); – Will B. Commented Nov 1, 2018 at 17:25
  • I tried your suggestion: $comments_by_type = (get_comments('status=approve&post_id=' . $id)); separate_comments($comments); return count($comments_by_type['comment']); it didn't work.....thanks for trying. – MBenson Commented Nov 1, 2018 at 18:51
  • You passed the wrong variable name to separate_comments as you never defined $comments, please see my answer. – Will B. Commented Nov 1, 2018 at 19:11
Add a comment  | 

1 Answer 1

Reset to default 1

The issue is caused by the arguments for separate_comments being passed by-reference. Source: function separate_comments(&$comments). This means passing a function as an argument is restricted.

To resolve the issue you need to assign the get_comments function results to a variable.

$comments = get_comments('status=approve&post_id=' . $id);
$comments_by_type = separate_comments($comments);
return count($comments_by_type['comment']);
Post a comment

comment list (0)

  1. No comments so far