-1
I would like to ask a question, I have a script where I count the total of files of a directory and compare with the files of the bank, everything is working.
My question is this:: When I put a code to be displayed the errors, displays an error, however it is working, I simply ignore and I shoot the error display? or I am using the count
wrong?
Warning: Count(): Parameter must be an array or an Object that Implements Countable in /example.php on line 69
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // Esse é o código que força mostrar o erro
foreach($files as $file){
if(!in_array($file, $images)){
echo "Cerca de <b>" .count($file). "</b> arquivo(s) que não estão no banco de dados <p>"; //Ele diz que tem erro nessa linha
echo "Nomes dos arquivos: <b>" . $file . "</b><br>";
}
}
It gives a warning, not error, as you are passing a value that is not an array in any case. Try to put a
is_array($file)
before using thecount()
.– rbz
is_array($file)
did not return anything... then, as is a warning, "no problem"– Douglas
The
is_array
is to check if it is an array only, then you print thecount
– rbz
Thanks @Rbz, you already answered my question.
– Douglas