Jump to content

Fluent Interface method call in an if statement


proggR

Recommended Posts

I'm working on an application and it seems that the else block is being executed no matter what in the following if statement. My question (which seems really basic and like I should know the answer but I can't seem to remember) is if you have an object instance in an if statement, how does that resolve? Will it resolve to true because there is an object there? I assume/think that would be the behaviour but I can't remember.

Also, I'll point out the class I'm working with is Zend_Mail. From my understanding the send method will return an instance of $this upon success and will throw an exception on failure. The mail is being sent but the else block is executing anyway. I may just throw it in a try catch if that's better.

	if ($mail->send()) {
		return true;
	} else {
		$NOTICE++;
		$NOTICESTR[] = "We were unable to e-mail an e-mail notification <strong>".$to["email"]."</strong>.<br /><br />A system administrator was notified of this issue, but you may wish to contact this learner manually and let them know their accommodation has been removed.";

		application_log("error", "Unable to send accommodation notification to [".$to["email"]."] / type [".$type."]. Zend_Mail said: ".$mail->ErrorInfo);
	}

 

 

Thanks in advance. I'll check back in a bit.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.