PHP测试对象属性

I need to test an object property for equivalence to a string.

I'm using the php imap functions to cycle through the 10 most recent emails in a gmail account, I want to filter them so I'm only dealing with email from twitter. This for loop is the relevant extract of code where things are going wrong.

for ($currentMsgno; $currentMsgno > (msgnoTotal-10); $currentMsgno--){
  echo "MESSAGE NO IS : " . $currentMsgno . "<br/>";

  $headerObj = imap_headerinfo($mbox,$currentMsgno,0,0);

  if ($headerObj->fromaddress=='Twitter'){
      echo "MESSAGE FROMADDRESS IS: " . $headerObj->fromaddress . "<br/>"
  }
  imap_setflag_full($mbox, "$currentMsgno", "\\Seen");
}

All of the code works okay apart from trying to test ($headerObj->fromaddress=='Twitter'), this simply doesn't work. I'm not sure if there is something very basic that i'm not doing when dealing with the objects property... is there a funciton I should be using?