1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

wrong with Switch ()?

Discussion in 'Development' started by Hoyee, Mar 4, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    $d=1;

    switch ($d){

    case 1;
    $player->sendMessage("1");
    if($d=1){
    $d=$d+1;
    }
    break;

    case 2;
    $player->sendMessage("2");
    if($d=2){
    $d=1;
    }
    break;



    or another code without if

    switch ($d){

    case 1;
    $player->sendMessage("1");
    if($d=1){
    $d=$d+1;
    break;

    case 2;
    $player->sendMessage("2");
    $d=1;
    break;
    }




    Is this Wrong? It doesn't work both of them.
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    What are you trying to do? To check if a variable is a certain value you have to do
    PHP:
    if($d === 1)
     
  3. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
  4. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    what is === ?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.