Suppress CRON Errors

I have a page that runs fine. I suppress the Notice errors by doing:
ini_set("display_errors","0");
and it works fine.

But when it runs as a CRON the cron report has the errors.
Notice: Undefined offset: 37 in /var/www/vhosts/*.com/httpdocs/page.php on line 89
Notice: Undefined offset: 37 in /var/www/vhosts/*.com/httpdocs/page.php on line 90

Is there a way to suppress errors in CRON reports?
function CSV2Array($contentx, $delim = ',', $encl = '"', $optional = 1) {
   if ($contentx[strlen($contentx)-1]!="r" && $contentx[strlen($contentx)-1]!="n")
       $contentx .= "rn";
 
   $reg = '/(('.$encl.')'.($optional?'?(?(2)':'(').
           '[^'.$encl.']*'.$encl.'|[^'.$delim.'rn]*))('.$delim.
           '|rn)/smi';
 
   preg_match_all($reg, $contentx, $treffer);
   $linecount = 0;
 
   for ($i = 0; $i<=count($treffer[3]);$i++) {
       $liste[$linecount][] = $treffer[1][$i]; ////Here is the first Notice Error
       if ($treffer[3][$i] != $delim)////Here is the second Notice Error
           $linecount++;
   }
   unset($linecount);
   unset($i);
   unset($reg);
   unset($contentx);
   unset($delim);
   unset($encl);
   unset($optional);
   unset($treffer);
 
   return $liste;
}

Open in new window

phperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dr_dedoCommented:
how do u call your script in cron ?
did u try to disable errors in php.ini ?
0
phperAuthor Commented:
I'm using Plesk to run the cron.
/usr/bin/php -f /var/www/vhosts/*.com/httpdocs/page.php

Errors are disabled in php.ini. I forgot, I put ini_set("display_errors","0"); in an effort to suppress the cron errors.
0
dr_dedoCommented:
maybe you should use this in line 12
for ($i = 0; $i<count($treffer[3]);$i++) {

seems you are always exceeding arrays offsets
0
PhatzerCommented:
How about supressing using the '@' before what you're doing? I'm not sure, however if this applies only when calling functions, but maybe worth a try:
   for ($i = 0; $i<=count($treffer[3]);$i++) {
       @$liste[$linecount][] = $treffer[1][$i]; ////Here is the first Notice Error
       if (@$treffer[3][$i] != $delim)////Here is the second Notice Error
           $linecount++;
   }

Open in new window

0
phperAuthor Commented:
Actually, I found that

ERROR_REPORTING(0);

stops the error reporting in the CRON report
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.