admin管理员组文章数量:1130349
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
|
1 Answer
Reset to default 1The 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']);
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_commentsare being passed by-reference asfunction separate_comments(&$comments). You would need to assignget_commentsto a variable.$comments = get_comments('status=approve&post_id=' . $id);Thenseparate_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_commentsas you never defined$comments, please see my answer. – Will B. Commented Nov 1, 2018 at 19:11
1 Answer
Reset to default 1The 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']);
本文标签: PHP Strict Standards Only variables should be assigned by reference
版权声明:本文标题:PHP Strict Standards: Only variables should be assigned by reference 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749213056a2333697.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


separate_commentsare being passed by-reference asfunction separate_comments(&$comments). You would need to assignget_commentsto a variable.$comments = get_comments('status=approve&post_id=' . $id);Thenseparate_comments($comments);– Will B. Commented Nov 1, 2018 at 17:25separate_commentsas you never defined$comments, please see my answer. – Will B. Commented Nov 1, 2018 at 19:11