为什么$ n = $ n + $ n无效[关闭]

I've tried out some code where I use a for loop in PHP to add up numbers but it seems to not work, how can be?

$n = 3; //or anything else
for($i=0;$i<$n;$i++){
   $n = $n+$n;
}
echo $n;

This is just a test code for something else, but I'd still like it to work, please help

You are increasing the loop ending condition $n inside the loop

this means it will never exit the loop.

this is an infinite loop, and wont ever print anything.

also your loop needs to be $i = 0; $i < $n; $i++