using markers instead of if and else statement in php

Posted by Mac Taylor on Stack Overflow See other posts from Stack Overflow or by Mac Taylor
Published on 2010-04-24T15:58:52Z Indexed on 2010/04/24 16:03 UTC
Read the original article Hit count: 253

Filed under:

hey guys

i need to shorten or better to say ., harden my codes

this is my original code :

if ($type = "recent") {
    $OrderType =  "sid DESC";
}elseif ($type = "pop"){
    $OrderType =  "counter DESC";
}else {
    $OrderType =  "RAND()";
}

now how can i use markers like this :

$OrderType = ($type = "recent") ? "sid DESC" : "counter DESC" ;

i tried but i didnt know how to write elseif in marker way

© Stack Overflow or respective owner

Related posts about php