Hi folks,

Michael Sims wrote:

MS> IMHO what you have described is a bug in PHP, and if I were you,
MS> I'd report it as such.  If it's not a bug it at least has a very
MS> high WTF factor.

Problem with reporting is that I am using Debian Test and the current
PHP version is too old to report. If someone with an current PHP
version could replicate the problem, let me know and I will report it.
Here is the code:

////////////////////////////////////////////////////////////////////
$foo = '' ;
$foo['one']['two'] = 'test-value' ;

print( '<b>Running tests for one non-existent key</b><br><br>' ) ;

// Test isset() for non-existent key

if( isset( $foo['one']['two']['three'] ) )
{
    print( "Unexpected isset(): evaluated to TRUE<br>" ) ;
}
else
{
    print( "Expected isset(): evaluated to FALSE<br>" ) ;
}

// Use var_dump() to find out what is going on
// Expected: evaluate to NULL
// Actual: evaluated to 'string(1) "t"'
// ("x" is the first char of "test-value")

print( 'var_dump() output (expecting NULL):<br>' ) ;
var_dump( $foo['one']['two']['three'] ) ;

// Add another non-existent key and things
// work as expected

print( '<br><br><b>Running tests for two non-existent keys</b><br><br>' ) ;

if( isset( $foo['one']['two']['three']['four'] ) )
{
    print( "Unexpected isset(): evaluated to TRUE<br>" ) ;
}
else
{
    print( "Expected isset(): evaluated to FALSE<br>" ) ;
}

print( 'var_dump() output (expecting NULL):<br>' ) ;
var_dump( $foo['one']['two']['three']['four'] ) ;

////////////////////////////////////////////////////////////////////



------------------ 
Geoff Caplan
Vario Software Ltd
(+44) 121-515 1154 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to