Re: [PHP] UNLESS Statement Equivalent

[email protected] (Jonathan Sundquist)
Newsgroups php.general
Message-ID <CAJYze7=ALDB=-JzGUuxc4ToNULtOFXXUGiEMmxWdfMpNy_XPtw@mail.gmail.com>
What you have

if ( ($current_page == $saved_page) and ($current_ip == $saved_ip) and
($current_dt < ($saved_dt + 3600)) ) {
        return;
} else {
        $query  = "UPDATE `table` SET `hits` = '$count', `agent` =
'$agent', `ts` = '$date_time'  WHERE `page` = '$page'";
        $result = mysql_query($query) or die ('Error! -- ' . mysql_error());
}

is the same as writing it as

if ( ($current_page == $saved_page) && ($current_ip == $saved_ip) &&
($current_dt < ($saved_dt + 3600)) ) {
        return;
}

$query  = "UPDATE `table` SET `hits` = '$count', `agent` = '$agent', `ts` =
'$date_time'  WHERE `page` = '$page'";
$result = mysql_query($query) or die ('Error! -- ' . mysql_error());



On Mon, Mar 11, 2013 at 5:48 PM, Angela Barone
<[email protected]>wrote:

> On Mar 11, 2013, at 2:38 PM, Jonathan Sundquist wrote:
>
> Since you already have the return statement with the if statement the else
> isn't required. If those three statements are true you would exit the call
> any ways
>
>
> I don't follow.  The else contains the meat of the statement.
>
> Angela
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.