Can you assign multiple variables at once in PHP like you can with Java?

前端 未结 5 467
伪装坚强ぢ
伪装坚强ぢ 2021-02-03 17:13

I want to create 5 variables of type array all at once. Is this possible? In Java I know you can, but can\'t find anything about PHP. I\'d like to do something like this:

<
5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 17:34

    $c = $b = $a;
    

    is equivalent to

    $b = $a;
    $c = $b;
    

    therefore:

    $var1 = $var2 = $var3 = $var4=  $var5 = array();
    

提交回复
热议问题