Some PHP Code Help

Discussion in 'PHP' started by Warez Dominator, Nov 13, 2011.

  1. #1
    Hello,

    Need help in PHP coding on the function

    Function Defined as

    "License Type" => array( "Type" => "dropdown", "Options" => "cPanel VPS License,cPanel Dedicated License, Softaculous VPS, Softaculous Dedicated" ),

    Where
    cPanel VPS License = 2
    cPanel Dedicated License = 1
    Softaculous VPS = 8
    Softaculous Dedicated = 7

    And i another Line above License Type called by using the code

    $license_type = License Type == "cPanel VPS License" ? "2" : "1";

    Work only for first two
    If want to add another two functions that os Softaculous VPS and Dedicated such as

    $license_type = License Type == "cPanel VPS License" ? "2" : "1" : "8" : "7";

    Then it not working so in short if we want to call more that 2 functions then how can it possible as call of two functions are working that is with 2 and 1 not 2,1,8,7 so can any one say how to fix it.

    Regards
     
    Solved! View solution.
    Warez Dominator, Nov 13, 2011 IP
  2. avinash gaud

    avinash gaud Member

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    26
    #2
    Hello,

    The ternanry operators is mostly used for two values the one which is true and other is false , not sure if it works for four values instead you can try if condition.
     
    avinash gaud, Nov 13, 2011 IP
  3. #3
    The ternary if means

    if license type is equal to cpanel vps license, make $license_type 2, otherwise make it 1. Since there are only 2 possible conditions (it is equal or it's not equal), you can have only 2 values. If you have other conditions to test you can add values, but you can't set one of 4 values based on one condition being true or false - that's only two choices.
     
    Rukbat, Nov 15, 2011 IP
  4. Warez Dominator

    Warez Dominator Member

    Messages:
    80
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #4
    Hello,

    Thanks all the issue is solved.

    Regards
     
    Warez Dominator, Nov 16, 2011 IP