You are here: Re: Undefined offset- how to prevent warning message? « All PHP « IT news, forums, messages
Re: Undefined offset- how to prevent warning message?

Posted by Fabian Hore on 09/28/47 11:41

read about PHP error levels.
you can have looser error reporting by setting as follows
error_reporting( E_ALL ^ E_NOTICE );

or suppress single expressions with '@'
@$constraintuno[$k] .= $s." + ";

errors are your friend - only supress in trival cases
like when getting from post when post may be empty
$data = @$_POST['thing'] or $data = 'no data here';




"Tom Peel" <notreallytandp@freenet.de> wrote in message
news:46qs8bFcjg1qU1@individual.net...
> I'm getting this message showing up in the apache error_log:
>
> PHP Notice: Undefined offset: 21 in
> /usr/local/apache2/htdocs/cargo/lpdriver.php on line 104
> The offending code line is:
>
> $constraintuno[$k] .= $s." + ";
>
> This is inside a loop where $k is integer and being being incremented on
> each iteration. The final value of $k, and hence the size of array
> $constraintuno, is of unknown size.
>
> I can get rid of the error message by using array_fill:
> $constraintuno = array_fill(0,1000,'');
>
> This is pretty ugly, because I cannot predict the final size of the array.
>
> Is there a good solution?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация