LoginSignup
1
0

More than 5 years have passed since last update.

PHPのカンマ演算子で無限ループした

Posted at

独習PHPしてて無限ループった話。(メモ)

for ($i = 1, $j = 1; $result = $i * $j, $i < 6; $i++, $j++) {
    …
}

って書くと予定通り動くけど

for ($i = 1, $j = 1; $i < 6, $result = $i * $j; $i++, $j++) {
    …
}

ってやると無限ループになる。
複数やるときは最後に持ってきた式が条件になるっぽい。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0