-3

With 7.2 i got error on function count()

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

is possible to disable showing these errors on server side like php.ini? I know how to fix in code but there is too much to change thats why i want to change server side

Rawelja
  • 109
  • 9
  • 1
    disable showing errors is not a good idea... but _@count()_ probably solve your problem – Sfili_81 Nov 30 '18 at 12:52
  • Where to add @count() ? – Rawelja Nov 30 '18 at 12:53
  • in your php code every time you use count(). P.s. this is not a good idea, better verify if you pass an array to the count function – Sfili_81 Nov 30 '18 at 12:54
  • In case you are using WordPress, see https://core.trac.wordpress.org/ticket/42814 – uruk Nov 30 '18 at 12:55
  • I work on Contao CMS – Rawelja Nov 30 '18 at 13:08
  • Please show us an example of the code that produces this error and also show us a `var_dump` of the variable that you're passing into `count`. – waterloomatt Nov 30 '18 at 19:31
  • I also had this problem, I had php 7.3 on local with MySQL DB and same version on the live server with Maria DB. On local it ignored the error also on other live server having MySQL ignored as well but retained on the live server which had MariaDB. There is more restriction and different settings of php `warning types` than on your local server. Try tweaking with some settings on your live server related to this warning or simply use @count() or use error_reporting. – Danial212k Mar 06 '21 at 15:00

1 Answers1

2

This is the answer to your question.

<?php
error_reporting(0); // Turns off all error reporting.
?>

As found very openly in the PHP documentation

However, I cannot stress enough how bad an idea this is, to resort to this, rather than solve your problem. With your given example, it just seems like laziness.

cmprogram
  • 1,854
  • 2
  • 13
  • 25
  • Project is very big. I cant search all and fix count problem thats why i want to change error showing – Rawelja Nov 30 '18 at 13:09
  • @Test That additional information doesn't change what I said about it. Regardless of the project size, this solution should be used for testing and development only. – cmprogram Nov 30 '18 at 13:17
  • I'd just ignore the warnings https://stackoverflow.com/questions/1987579/remove-warning-messages-in-php (If I were to disable some reporting, I wouldn't actually do either though) – user3783243 Nov 30 '18 at 13:21
  • 2
    @Test ... then you have a `very big` flaky project. Best advice : fix all warnings/errors, they have a way of causing errors. Get yourself a proper IDE if you dont have one. – YvesLeBorg Nov 30 '18 at 15:43