php - understanding nested ternary operators -


i have piece of code unclear me, complex use of ternary operators

if (!$byfield && is_numeric($v)){ // id $r=$fromrow? $fromrow: ($v? dbrow("select * pages id=$v limit 1"): array() ); } 

if explain how evaluate nested use of ternary operators

consider following code:

<?php     $a = true;     $b = false;     $c = true;      echo (         $a          ? 'a true'         : (             $b              ? 'a false, b true'             : (                 $c                  ? 'a false, b false, c true'                 : 'a, b , c false'             )         )     ); ?> 

which rewritten so:

<?php     if ($a) {         echo 'a true';     } else {         if ($b) {             echo 'a false, b true';         } else {             if ($c) {                 echo 'a false, b false c true';             } else {                 echo 'a, b , c false';             }         }     } ?> 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -