Strange isset behavior

isset () in php 5.3 seems to behave unexpectedly. I have a class called DB that encapsulates a bunch of string properties using getters and setters.

$ dbdetails-> getDatabasename () evaluates the string ("mydb")

This raises a 500 error:

if(!isset($dbdetails->getDatabasename())){
//do something
}

That works great

$databasename = $dbdetails->getDatabasename();
if(!isset($databasename)){
//do something
}

I could not see any log output because apache sent back 500 even if the ini param parameter is set (sic) to On. I know this is precisely related to isset call. Any idea what might be wrong, or did I find a PHP error?

+3
source share
2 answers

isset , ​​ . $databasename , , ​​ . , .

, is_null( $value ) .


is_null:

<?php
function test( ) { return null; }
var_dump( is_null( test( ) ) ); // displays "true"
var_dump( isset( test( ) ) ); // parse error, because "test()" is not a variable
?>
+6

isset(). , empty(). , . :

isset() , - . , , defined().

, isset(function_call()) .

+4

All Articles