NYCPHP Meetup

NYPHP.org

[nycphp-talk] Any ideas appreciated... short cuts are not always a good thing for script maintenance... need some advise...

leeeyerman at aol.com leeeyerman at aol.com
Fri Oct 19 23:02:20 EDT 2007


I believe you are correct except for the else.? The if statement can be written that way, but it will not do the else statement you put in your example, you would include that...

http://us.php.net/manual/en/language.control-structures.php#control-structures.if

This is a good link to learn how to write the shorter version of the if statement.? However, I like writing it out... old school.




I thinks this is the equivalent of:

if ( !mail( $row['Email'], $row[Subj], $row[Body], "From: $site[email_notify]", 
"-f$site[email_notify]") )
{
++$err;  //update the error queue
}
else
{
mail( $row['Email'], $row[Subj], $row[Body], "From: $site[email_notify]", 
"-f$site[email_notify]");
}




-----Original Message-----
From: mikesz at qualityadvantages.com
To: talk at lists.nyphp.org
Sent: Fri, 19 Oct 2007 8:47 pm
Subject: [nycphp-talk] Any ideas appreciated... short cuts are not always a good thing for script maintenance... need some advise...



Greetings and Hello,

I am converting a script to use SMTP if php mail() is not available
for the users of this script. I have all the active calls working so
that if my smtp flag is set it automatically switches to smtp and
sends the message with the appropriate headers etc. but part of the script is 
run by a
cron job and I see a php mail call but don't quite understand the syntax.
Anyone care to take a guess at translating what it does?

It is part of a while loop and I think its combining two conditions
into one statement but would like confirmation.

here is the code fragment:

if ( !mail( $row['Email'], $row[Subj], $row[Body], "From: $site[email_notify]", 
"-f$site[email_notify]") )
++$err;


I thinks this is the equivalent of:

if ( !mail( $row['Email'], $row[Subj], $row[Body], "From: $site[email_notify]", 
"-f$site[email_notify]") )
{
++$err;  //update the error queue
}
else
{
mail( $row['Email'], $row[Subj], $row[Body], "From: $site[email_notify]", 
"-f$site[email_notify]");
}


Has anyone seen or used this technique before? This is the first time
I have seen it used, though this script has a lot of short cuts that
make the code difficult to debug sometimes, like this one.

Thanks in advance for your comments,
-- 
Best regards,
 mikesz                          mailto:mikesz at qualityadvantages.com

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php


________________________________________________________________________
Email and AIM finally together. You've gotta check out free AOL Mail! - http://mail.aol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20071019/8f58e42a/attachment.html>


More information about the talk mailing list