I need some guidance with a exercise I was set as part of my PHP class. I've tried many different methods but none that satisfy the requirements. The task is to do the following:
Prerequisite :
Using only 4 lines of code
<?php
, ?>
tags count as one line each. Output: print the following text 200 times
“All work and no play makes jack a dull boy.”
I'm assuming it requires the use of a while loop but I've exhausted my knowledge of PHP and simply can't come up with a solution. I'm not necessarily looking for the answer just to be pointed in the right direction.
Thank you.
Not sure if I got it or not, but heres my try...
function printsth ($count) {
echo $count++, "All work and no play makes jack a dull boy.<br>", $count <= 200 ? printsth($count++) : "";
}
printsth(1);
cleaner version
function printsth ($count) {
echo "All work and no play makes jack a dull boy.<br>", $count++ < 200 ? printsth($count++) : "";
}
printsth(1);