Reputation: 13844
I have the following if condition statement
if ( (strlen($data[70])>0) || ( (remove19((trim($data[29])) == '7135556666')) && isLongDistance($data[8])) )
where $data is a recordset from a database.
My goal is to include all rows where $data[70] isn't blank, and also include rows where $data[29] = 713555666 && $data[8] isLongDistance = TRUE
My question is, if isLongDistance($data[8]) returns false, will it still return the row since $data[70] is not blank?
thanks in advance
Upvotes: 0
Views: 114
Reputation: 32888
Yes it is. But to understand realy what it does write code that humans can understand, dont write code just for the computers.
consider this simplefied version.
$dataLenght = strlen($data[70]);
$remove19 = remove19((trim($data[29]);
$longDistance = isLongDistance($data[8]);
if ( $dataLenght > 0 ) // your first OR if false it would goto elseif statement
{
//condition
}
elseif( $remove19 == '7135556666' && $longDistance) // your second statement
{
//conditon
}
Upvotes: 0
Reputation: 309
If the first thing returns TRUE then the if will succeed. If first thing will return FALSE, then it will execute the part after OR and if the number is correct and the function returns TRUE, then it will succeed.
Anyway I would overwrite it like this
if ( !empty($data[70]) or ( (int)$data[29] == 7135556666 and isLongDistance($data[8]) )
Upvotes: 0
Reputation: 4498
Yes, because you're doing an OR. Your statement will reduce to "TRUE OR (TRUE AND FALSE)", which will be TRUE.
Upvotes: 3