[thelist] PHP ternary operator question

Faust at LeeMarvin.com Faust at LeeMarvin.com
Fri Jun 28 11:23:01 CDT 2002


Why isn't this

$daily = (($MTArchiveDate_timestamp <= $today_timestamp) &&
($today_timestamp <= $MTArchiveDateEnd_timestamp) &&
file_exists($today)) ? $today              :
         (($first_of_the_month_timestamp >= $first_of_the_week_timestamp)
&& file_exists($first_of_the_month))                        ? $first_of_the_month :
/$daily = (($MTArchiveDate_timestamp <= $today_timestamp) &&
($today_timestamp <= $MTArchiveDateEnd_timestamp) &&
file_exists($today)) ? $today              :
         (($first_of_the_month_timestamp >= $first_of_the_week_timestamp)
&& file_exists($first_of_the_month))                        ? $first_of_the_month :
 			   (file_exists($first_of_the_week))
                                                                ? $first_of_the_week  :

                        0;
equivalent to this

if (($MTArchiveDate_timestamp <= $today_timestamp) &&
($today_timestamp <= $MTArchiveDateEnd_timestamp) &&
file_exists($today)) {
   $daily = $today;
}
elseif (($first_of_the_month_timestamp >= $first_of_the_week_timestamp)
&& file_exists($first_of_the_month)) {
   $daily = $first_of_the_month;
}
elseif (file_exists($first_of_the_week)) {
   $daily = $first_of_the_week;
}
else {
   $daily = 0;
}

?

TIA

Faust



More information about the thelist mailing list