dsoy71058 2011-05-30 18:23
浏览 26
已采纳

如何在某些条件下做两个平等的陈述?

I need to use different modules based on what value the $what variable holds. There are 2 variables; me and others. If $what = me i want them to see me.php an if $what = others i want them to see others.php. I don't know how to update the snippet that will also take $what = other scenario under consideration.

How to do that?

  $what = "me";

  if ( $q === $what ) {
require("me.php");
  } else {
  require("all.php");
  }
  • 写回答

6条回答 默认 最新

  • duan111112 2011-05-30 18:27
    关注

    You need elseif statement.

     $what = "me";
    
     if ( $q === $what ) {
        require("me.php");
     } elseif ($what === "others") {
        require("all.php");
     } else {  // optional "catch all condition"
       die("Should not be here");
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示