PHP空测试验结果不一致

I'm pulling in an XML file and performing various massaging of data. I assigned an element (which has no data) to a variable and tested whether the variable is empty. The test was false. Not sure why, I tested the element directly and it passed as true. Baffled by this, I put the variable through several conditions, just to see what I was dealing with. This has left me perplexed, as the results seem entirely inconsistent to me. The code I put this through is as follows:

$xmldata = simplexml_load_file('data.xml');
$picture = $person->picturefile;       <--picturefile is empty
if (!empty($person->picturefile)) {
    echo "picture is not empty";
    } else {
    echo "picture is empty";
    }

if (!empty($picture)) {
    echo "picture is not empty";
    } else {
    echo "picture is empty";
    }

$tempfile = "members/$picture";
if (file_exists($tempfile)) {
   echo "<div class=mgridimg><img src=$tempfile></div>";
}

The test of the xml path yields a false condition (picture is empty), but the test of the variable yields a true condition (picture is not empty).
I put the variable through a strlen test and it showed strlen = 0.

From the xml file, $picture, when populated, has a file name. Just as baffling, although $picture is empty, the file_exists test passes as true. I've also verified that in the above test, $tempfile contains a value of "members/". I can't make sense of the empty test of the variable or the file_exists test. I can code around this, but am wondering why I am seeing what I'm seeing. Any insight is appreciated.

For the first case it seems for me nearly impossible to be true. They both should be equal. Have you tried trimming?

For the file_exists function, if you don't want to be true on dir's, you should check for !is_dir()

E.g.:

var_dump(file_exists('New Folder/'));

var_dump(file_exists('New Folder/') && !is_dir('New Folder/'));

var_dump(file_exists('New Folder/New Text Document.txt') && !is_dir('New Folder/New Text Document.txt'));

outputs:

boolean true

boolean false

boolean true