Can i use divide in loop for PHP ?
I write code like that but not work.
<?PHP
for ($k=100;$k>2;$k/2)
{echo $k;}
?>
That should be $k = $k / 2
, or $k /= 2
.
As pointed out in the comments, you could also use a bit shift operation $k >>= 1
.
Try with:
for ($k=100;$k>2;$k = $k/2) {
echo $k;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.