windows98
V2EX  ›  问与答

怎么样优雅的维护 API 接口里面的各种客户端版本特殊逻辑

  •  
  •   windows98 · Sep 1, 2016 · 1076 views
    This topic created in 3551 days ago, the information mentioned may be changed or developed.
    这些接口为了兼容客户端版本出现了如下代码,每次有个什么升级基本就是怼代码,各自版本判断,平台判断。有啥优雅的方案解决

    if(VERSION > 1.0.0 && VERSION < 1.5.0) {
    $conf = "a_inc.php";
    } else if(VERSION >= 1.5.0) {
    $conf = "a_inc_new.php";
    }

    if(PLATFORM == "zh") {
    $conf = "b_inc.php";
    } else if (VERSION == "en") {
    $conf = "b_inc_new.php";
    }
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2211 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 00:33 · PVG 08:33 · LAX 17:33 · JFK 20:33
    ♥ Do have faith in what you're doing.