Contents


Solution VIII

File sol_VIII_a.php is the file to be opened in the browser, it includes itself: <? require_once( "sol_VIII_b.php" ); print f()." "; include( basename($_SERVER['PHP_SELF']) ); ?> File sol_VIII_b.php is required once of define the function f(): <? function f() { $students = array("fred","john","jim","mary"); return $students [array_rand($students,1)]; } ?> This construct avoids the allocation of memory (for some variable) when sol_VIII_a.php is included. Otherwise the recursive include operation would cause a memory overflow.