duanlu1922 2018-01-28 19:39
浏览 78
已采纳

我如何将2个用户排名合并为一个

Okay im stumped as im wondering how would i merge 2 user ranks into one.

1st user rank <?php if ($user -> isAdmin($odb)) { ?>

2nd user rank <?php if ($user -> isStaff($odb)) { ?>

  • 写回答

3条回答 默认 最新

  • doudengjin8251 2018-01-28 20:10
    关注

    The "or" is actually not needed.
    Your functions seems to return a boolean answer.
    And boolean can be interpreted as 0 and 1 in a if.

    if ($user -> isAdmin($odb) + $user -> isStaff($odb))
    

    So by adding them together you get an answer from 0-2.
    Where 0 is false, false and true, true is 2.
    Since 1 and 2 is interpreted as true in PHP it will work without the or.

    Try it out here: https://3v4l.org/rWf6C

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图