0

My code works but this warning is generated:

Code:

$config = ["title" => "Title Test","Body" => "Body Test"];

if(count($config["title"]) > 0) {

  echo "OK";

} else {

  echo "ERROR";

}

Warning:

[25-Feb-2020 13:32:49 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/...

Mujahid Bhoraniya
  • 1,518
  • 10
  • 22
  • The warning is explaination enough I'd have thought. It is telling you that `$config["title"]` is not an array or an object that implements Countable... – George Feb 25 '20 at 13:52
  • Because you targetted $config["title"], which is the output is string "Title Test". The parameter inside count() must be array. If you want to check the string type, use empty() function. – Muamar Ali Mar 06 '20 at 09:48

0 Answers0