performance - php - efficiency of if conditions - nested or using the AND method? -


in php, can use nested if structure, or can combine conditions using && method ... there known differences in regards performance/efficiency? (is 1 known/established faster, or less resource intensive etc.?)

nested:

if ($x == $y) {     if ($n >= $p) {         if ($tt != true) {             //         }     } } 

or combined and:

if ($x == $y  &&  $n >= $p  &&  $tt != true) {     // } 

i know appears duplicate of
php nested ifs vs single if multiple conditions
because wasn't answered (instead people linked things in java etc.).

so please don't flag dupe, or link answers of non-php questions etc.

talking of efficiency, don't think there difference in both. if 1 boolean decision false in 1 line statement, remaining decisions won't evaluated , similar happens in nested if statements.

but readability , clarity matters. making nested if each individual condition make code unnecessarily lengthy whereas many statements in 1 line make difficult follow long horizontal statements bit unclear. try keep related conditions multiple if statements , conditions different concept nested if statements.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -