Message: count(): Parameter must be an array or an object that implements Countable

Message: count(): Parameter must be an array or an object that implements Countable

In Php 7.2 Version count function does not support. It Supports in previous version of php like 5.2 or anything else. if you using php 7.2 as server language and if you facing these problem here in this my cyber programming tutorial have a solution let us check out.  if you using Cordeigniter or larvel as a Framework with php  if you facing these problem like parameter must be an array or an object that implements countable. this err_handler .message count(). hey just don’t worry about that please visit my website . i hope you will enjoying of every solutions. let  us solve this error.

Here   this is the problem where  most of the beginners  or  developers facing these kind of issue. 

 here (:) it means { curly braces . you can also use this instead of this please make sure both are correct i want to only reduce the code. 


Problem Using : instead of Curly braces. {,}

<?php if(count($articles)): ?>
<?php foreach ($articles as $art): ?>
<tr>

<td>karan</td>
<td>singhania</td>
<td>developer</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan=”3″>Not data available</td>
</tr>
<?php endif; ?>

Same Problem Using { } 

<?php if(count($articles)) { ?>
<?php foreach ($articles as $art) { ?>
<tr>

<td>karan</td>
<td>singhania</td>
<td>developer</td>
</tr>
<?php   } ?>
<?php else { ?>
<tr>
<td colspan=”3″>Not data available</td>
</tr>
<?php  } ?>


Let us Try these Code instead  of this . it will surely 100% working. let us try guys.

Solutions Using : instead of Curley braces. {,}


<?php if (is_array($articles)): ?>
<?php if ( $articles > count($articles)) : ?>
$articles =count($articles);
<?php foreach ($articles as $art) : ?> <tr>
<td>karan</td>
<td>singhania</td>
<td>developer</a></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php else: ?>
<tr>
<td colspan=”3″>No data Available</td>
</tr>
<?php endif; ?>

Solutions Using {, } 

<?php if (is_array($articles)) { ?>
<?php if ( $articles > count($articles)) {  ?>
$articles =count($articles);
<?php foreach ($articles as $art) : ?> <tr>
<td>karan</td>
<td>singhania</td>
<td>developer</a></td>
</tr>
<?php  }?>
<?php  } ?>
<?php else { ?>
<tr>
<td colspan=”3″>No data Avaialble</td>
</tr>
<?php  } ?>


 

Leave a Reply

Your email address will not be published. Required fields are marked *