这样使用while循环很奇怪?解决思路

WBOY
Release: 2016-06-13 10:15:14
Original
888 people have browsed it

这样使用while循环很奇怪?

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->        $pnum=91;        $randNum=0;        while($pnum>18){                        $randNum=$pnum/2;            if($randNum
Copy after login


我的本意是想获取比18小的数字,
可是,得出的是45.5?

请问错在哪里?

------解决方案--------------------
while这样用:

$pnum = 91;
while($pnum >= 18){
$pnum /= 2;
}
echo $pnum;

------解决方案--------------------
死的不能在死的循环。
我的本意是想获取比18小的数字??你的这个是什么需求?有点糊涂

PHP code
 $pnum=91; $randNum=0; while($pnum>18){                 $randNum = $pnum = $pnum/2;     if($randNum
                 
              
              
        
            
Copy after login
Related labels:
source:php.cn
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