If I check for isset($var), I won't be able to differentiate between following 2 cases. In the first one, I am explicitly setting $t1->a to null whereas in the second, it's left unchanged.
<?php
class Test {
public $a;
}
$t1 = new Test();
$t1->a = null;
if(isExplicitlySet($t1->a)) {
echo "yes t1\n";
}
$t2 = new Test();
if(isExplicitlySet($t2->a)) {
echo "yes t2\n";
}
function isExplicitlySet($var) {
//what goes here?
}
Edit : Reason I need this feature is : Before persisting an object of class Test to Database, I need to know if $a was explicitly set to null or was left unchanged. In the later case, I would set it to its default DB value as specified in the table definition.