[ create a new paste ] login | about

Link: http://codepad.org/W1hGPiKY    [ raw code | output | fork ]

PHP, pasted on Jan 12:
<?php

    $arr = array( 'request' => '' );
    test( $arr );

    $arr = array( 'request' => '', 'page' => '' );
    test( $arr );

    $arr = array( 'request' => '', 'page' => '0' );
    test( $arr );

function test( $arr )
{
    echo str_repeat( '=', 10 );
    echo PHP_EOL;
    echo '# If $arr is declared as:';
    echo PHP_EOL;
    var_dump( $arr );
    echo '# Then empty( $arr[\'page\'] ) is :';
    echo PHP_EOL;
    var_dump( empty( $arr['page'] ) );
    echo PHP_EOL;
}


Output:
==========
# If $arr is declared as:
array(1) {
  ["request"]=>
  string(0) ""
}
# Then empty( $arr['page'] ) is :
bool(true)

==========
# If $arr is declared as:
array(2) {
  ["request"]=>
  string(0) ""
  ["page"]=>
  string(0) ""
}
# Then empty( $arr['page'] ) is :
bool(true)

==========
# If $arr is declared as:
array(2) {
  ["request"]=>
  string(0) ""
  ["page"]=>
  string(1) "0"
}
# Then empty( $arr['page'] ) is :
bool(true)



Create a new paste based on this one


Comments: