7
In PHP, it is possible to generate a loop infinity with while
simply passing the parameter true
.
Example:
while (true) {
echo "Ao infinito e além";
}
It is also possible to generate this through for
, simply omitting the parameters, passing the ;
.
Example:
for(;;) {
echo "Não lembro o desenho que usa a frase acima";
}
Is there any functional difference between the two?
Change the performance?
Is there some advantage and disadvantage between one and the other?
I believe that because they are infinite loops, both are equal in terms of performance, but let’s wait for someone with more knowledge about...
– mauricio caserta