Javascript to PHP else if ": ?" operator conversion -
i have never encountered in javascript far although aware : ? means else if. having trouble figuring out how lay out in php. here did - going wrong if wrong?
jscript
var midparams = dparams2.isramped() ? dparams2 : dailyparams.avg(dparams1, dparams2);
php
$midparams = $dparams2->isramped() if $dparams2 = $midparams else $dailyparams->avg($dparams1, $dparams2);
you've got 2 options. 1st 1 same javascript
$midparams = ($dparams2 -> isramped()) ? $dparams2 : $dailyparams->avg($dparams1, $dparams2);
the second 1 more trivial:
if ($dparams2 -> isramped()) { $midparams = $dparams2; } else { $midparams = $dailyparams->avg($dparams1, $dparams2); }
first 1 says: midparams dparams if statement before true, or $dailyparams->avg($dparams1, $dparams2) if not. second same thing in more straight forward fashion.
Comments
Post a Comment