«^»
3.5. Is it possible to execute an infinite loop?

Is it possible for a PHP script to execute an infinite loop and eat up lots of cpu-time on the WWW server? Here is a PHP script to try this:

0067: <HTML><BODY>
0068: <?php
0069:    $count = 0;
0070:    while (true) {
0071:       $today = date("Y-m-d");
0072:       $count++;
0073:       print "count is: $count and today is: $today.<BR>";
0074:    }
0075: ?>
0076: </BODY></HTML>

Note: this PHP script uses a pre-defined function called date: this will be discussed later.

Go to the script at: http://www.dur.ac.uk/barry.cornelius/papers/phpintro/code/loop.php

The default is to allow a PHP script 30 seconds of cpu-time: it is possible to configure PHP so as to use a different value.