Difference between revisions of "PHPEX02"

From mi-linux
Jump to navigationJump to search
 
(10 intermediate revisions by one other user not shown)
Line 5: Line 5:
 
Define a constant 'my_year' equal to the year of your birth.   
 
Define a constant 'my_year' equal to the year of your birth.   
  
A loop should randomly generate numbers in the range 1900 to 1999, each number should be displayed on screen.  This should continue until the number which has been randomly generated matches the year of your birth.  The code to generate a random number in this range is given below:
+
A loop should randomly generate numbers in the range 1900 to 1999, each number should be displayed on screen.  This should continue until the number which has been randomly generated matches the year of your birth, for example:
 
 
<pre>
 
<?
 
    $any_year = rand(1900, 1999);
 
    print $any_year;
 
?>
 
</pre>
 
 
 
Your page should display something along these lines:
 
  
 
<pre>
 
<pre>
Line 25: Line 16:
 
</pre>
 
</pre>
  
Make sure that your page's HTML is [http://validator.w3.org/ valid]!
+
Note: The code to generate a random number in this range is given below:
 +
 
 +
<pre>
 +
<?php
 +
    $any_year = rand(1900, 1999);
 +
    print $any_year;
 +
?>
 +
</pre>
 +
 
 +
'''Important: you should commit your mini-task code to your Git project.'''
 +
 
 +
= Ready to move on? =
 +
When done, please proceed to the [[PHP108|next section]].

Latest revision as of 12:06, 20 September 2023

Main Page >> Web Application Development >> Workbook >> Mini-task 02

Mini-task - week 02

Define a constant 'my_year' equal to the year of your birth.

A loop should randomly generate numbers in the range 1900 to 1999, each number should be displayed on screen. This should continue until the number which has been randomly generated matches the year of your birth, for example:

1914
1967
1987
1955
1901
1976 => This is when Alix was born!

Note: The code to generate a random number in this range is given below:

<?php
    $any_year = rand(1900, 1999);
    print $any_year;
?>

Important: you should commit your mini-task code to your Git project.

Ready to move on?

When done, please proceed to the next section.