简体   繁体   中英

PHP 7.3 Warning: count(): Parameter must be an array or an object that implements Countable

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

$tags=locchuoi($request,"<span class='SeoH1'>",'</span>');
for($ll=1;$ll<count($tags)+1;$ll++)
{
    $tag_link =   $tag_link.$tags[$ll].",";
}

simple replace Count with !empty your problem is solved

 $tags=locchuoi($request,"<span class='SeoH1'>",'</span>'); for($ll=1;$ll<=(!empty($tags) ? count($tags) : 0);$ll++) { $tag_link = $tag_link.$tags[$ll].","; }

$tags=locchuoi($request,"<span class='SeoH1'>",'</span>');
for($ll=1;$ll<(!empty($tags) ? count($tags)+1 : 0);$ll++)
{
   $tag_link =   $tag_link.$tags[$ll].",";
}

Try this code, I just add some condition inside the for() , when the $tags varible is empty return 0 , if not return count($tags)+1 .

print_r($tags);

use this and check the output of tags. it might be null, so you are getting like this.check

 `locchuoi($request,"<span class='SeoH1'>",'</span>');` 

this function is returning the exact output which you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM