简体   繁体   English

遇到 PHP 错误严重性:通知消息:未定义的属性:stdClass::$comment_count 文件名:blog/index.php 行号:35

[英]A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$comment_count Filename: blog/index.php Line Number: 35

My line number 35 of view/blog/index.php is as:我的 view/blog/index.php 的第 35 行是:

<a href="<?php echo base_url().'post/'.$post->entry_id.'#comments';?>" class="comments">Comments (<?php echo $post->comment_count;?>)</a> 

I have made a column in table comment as comment_id still its not working我在表注释中创建了一个列,因为comment_id仍然不起作用

and in my model/blog_model.php it is a function as:在我的model/blog_model.php它是一个函数:

$count = array(
        'comment_count' => $total_count,
    );

Thanks in advance提前致谢

You are mixing up your notations.你正在混淆你的符号。 Question isnt very clear but if you have set an array index like...问题不是很清楚,但是如果您设置了一个数组索引,例如...

$count = array(
    'comment_count' => $total_count,
);

And I assume passing $count as $post into your view and trying to access like this...我假设将$count作为$post传递到您的视图中并尝试像这样访问......

$post->comment_count 

It wont work as this is not array notation.它不会工作,因为这不是数组表示法。 Correct would be..正确的应该是..

$post['comment_count']

If $post and $count are different objects then you need to do..如果$post$count是不同的对象,那么你需要做..

$count['comment_count']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 遇到 PHP 错误严重性:注意消息:试图获取非对象的属性文件名:blog/index.php 行号:23 - A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: blog/index.php Line Number: 23 遇到PHP错误严重性:通知消息:未定义的属性:stdClass :: $ file文件名:controllers / arsip.php行号:137 - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$file Filename: controllers/arsip.php Line Number: 137 遇到PHP错误严重性:通知消息:未定义的属性:stdClass :: $ abbrev - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$abbrev 遇到PHP错误严重性:通知消息:未定义的属性:Social :: $ social_model文件名:controllers / social.php行号:10 - A PHP Error was encountered Severity: Notice Message: Undefined property: Social::$social_model Filename: controllers/social.php Line Number: 10 遇到PHP错误严重性:通知消息:未定义的属性:CI_Loader :: $ p文件名:Templates / public.php行号:24 - A PHP Error was encountered Severity: Notice Message: Undefined property: CI_Loader::$p Filename: Templates/public.php Line Number: 24 遇到PHP错误严重性:通知消息:未定义的属性:stdClass :: $$ moderator_id,使用codeigniter - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$moderator_id, using codeigniter 代码点火器:遇到PHP错误严重性:注意消息:未定义的变量:页面文件名:admin / display_page.php行号:18 - Code Igniter: A PHP Error was encountered Severity: Notice Message: Undefined variable: page Filename: admin/display_page.php Line Number: 18 遇到 PHP 错误严重性:警告消息:未定义属性:stdClass::$cancelled - A PHP Error was encountered Severity: Warning Message: Undefined property: stdClass:: $cancelled 遇到 PHP 错误严重性:警告消息:未定义属性:stdClass::$cancelled - A PHP Error was encountered Severity: Warning Message: Undefined property: stdClass::$cancelled 遇到 PHP 错误严重性:通知消息:未定义索引:问题 - A PHP Error was encountered Severity: Notice Message: Undefined index: questions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM