Re: Could this be a bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 14, 2010 at 02:46, Thijs Lensselink <dev@xxxxxxxx> wrote:

>  On 09/14/2010 08:33 AM, Thijs Lensselink wrote:
>
>>  On 09/14/2010 12:16 AM, Camilo Sperberg wrote:
>>
>>> I have some really strange behaviour going on here, and I think it could
>>> be
>>> a (minor) PHP's bug.
>>> I am not really sure about what happens internally, but my best guess
>>> would
>>> be that after a memory exhaustion, when I try to execute a custom error
>>> handler with the register_shutdown_function (which is executed even after
>>> a
>>> fatal error) and try to access the element that provoked the memory
>>> exhaustion, no error should raise instead of *Uninitialized string
>>> offset:
>>> 0.
>>>
>>> I have prepared a little test case to reproduce the error and (I hope)
>>> can
>>> explain the error.
>>>
>>> <?php
>>> date_default_timezone_set('America/Santiago');
>>> ini_set('memory_limit','1M');
>>> ini_set('display_errors',1);
>>> error_reporting(-1);
>>>
>>> function my_error_handler($errno = '0', $errstr = '[FATAL] General
>>> Error',
>>> $errfile = 'N/A', $errline = 'N/A', $errctx = '') {
>>>
>>
> This seems to be your error. You set $errctx to be a string. But later on
> you use it as an array.
> Remove the = '' part. And it will function as expected.


You're right... However I don't like leaving non-default value in functions
so I did something like if(empty($errctx)) $errctx = array() in the first
line of the custom error handler which threw out the error message and
everything works ok now.

But -and correct me if I'm wrong- isn't isset (or empty) supposed to return
a FALSE whenever that variable doesn't exist?

With your help, I could reduce the test case into:

$asdf = 'hello world';
if (empty($asdf[4]['inventing'])) echo 'nice little world';
if (isset($asdf['inventing'][6])) echo 'little nice world';
// This works ok.

$asdf = '';
if (empty($asdf[4]['inventing'])) echo 'nice little world';
if (isset($asdf['inventing'][6])) echo 'little nice world';
// This returns E_NOTICE

Shouldn't these 2 examples work exactly the same way? (AKA as Nº 1). If
not... why not? Both are string types, onyl difference is that one has no
characters in it while the other does, but essentialy they are both the
same.

Greetings !

-- 
Mailed by:
UnReAl4U - unreal4u
ICQ #: 54472056
www1: http://www.chw.net/
www2: http://unreal4u.com/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux