Home > Backend Development > PHP Tutorial > 为啥循环不出来这个数呢

为啥循环不出来这个数呢

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:39:26
Original
864 people have browsed it

$no=0;
            while($bqrf=$empire->fetch($cx)) {
            if($no%1==0){
                $num=1;
             }elseif($no%2==0){
                $num=2;
             }elseif($no%3==0){
                $num=3;
             }
           $no++;
           echo $no;//有值,能循环出来1,2,3,4...................
           echo $num;输出的全是1
上面的$num不能按要求输出,不知为啥


回复讨论(解决方案)

因为全进入 if($no%1==0){ } 这个if了。

 数学啊数学

任何正整数求余1都是0,

 if($no%1==0){                $num=1;
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template