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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -