Home  >  Q&A  >  body text

Switch必须赋初始值,值与每个case值匹配。这句话中的“赋初始值”是什么意思?

checkcheck2764 days ago821

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:22:17

    Switch must be assigned an initial value, and the value matches each case value. What does "assign an initial value" mean in this sentence? -PHP Chinese website Q&A-Switch must be assigned an initial value, and the value matches each case value. What does "assign an initial value" mean in this sentence? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 迷茫

    迷茫2016-12-21 10:46:39

    注意语法:x 就是需要赋初始值的变量,只有该值被赋值后,后面的case代码块才能根据其值执行相应的代码内容

    switch(x){

    case x值1:

    执行的代码块1;

    break;

    case x值2:

    执行的代码块2;

    break;


    reply
    2
  • Cancelreply