Infinite loop in PHP & Python


Read {count} times since 2020

Infinite loops are loops that doesn’t have a defined ending. It will continue to run until the program it’s running in is terminated. Normally an infinite loop is created using while loop and is used for continuity of the same program.

In this short tutorial, you will learn how to make an infinite loop in both PHPPython.

PHP

There is no need of defining any variables.

while(1){
  print "Hello"
}

 

It can be done in two other ways :

while(True){
  print "Hello"
}
for (;;) {
  print "Hello"
}

Python

Same as before, but with some minor changes :

while(True) :
   print "Hello"