HuggieBear Posted November 2, 2006 Share Posted November 2, 2006 Below is a section of code I use in one of my classes, send_html is one of the functions inside the class. It all works fine, but I want to shorten it, so can I replace the first block of code with the second block?[code]<?phpfunction send_html() { $headers = "Content-type: text/html\n\n"; $result = mail($this->to, $this->subject, $this->body, $headers); if ($result){ return true; } else { return false; }}if ($mail->send_html()){ echo "Message sent OK";}else { echo "Message failed";}?>[/code][code]<?phpfunction send_html() { $headers = "Content-type: text/html\n\n"; return mail($this->to, $this->subject, $this->body, $headers);}if ($mail->send_html()){ echo "Message sent OK";}else { echo "Message failed";}?>[/code]I guess what I'm asking, is can I return the value of a php function within my user defined function, directly through to the calling script?RegardsHuggie Quote Link to comment Share on other sites More sharing options...
trq Posted November 2, 2006 Share Posted November 2, 2006 [quote]can I replace the first block of code with the second block?[/quote]Of course. The mail function returns true or false and yes, you can just pass it on. Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted November 2, 2006 Author Share Posted November 2, 2006 Thanks Thorpe, I thought as much but wouldn't want to look a fool when replying to post saying as much.RegardsHuggie Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.