Site icon sharedsapience.info

PHP Mathematical Function Quiz: lcg_value(); log10(); log1p(); log(); max(); min(); and mt_getrandmax().

An example of the quiz sized for desktop viewing.

PHP Quiz: lcg_value() + 6 Desktop Layout

HOW THE QUIZ WORKS:

Clicking the ‘randomize’ button situated above the reference table generates a new table whereby the function descriptions, function syntaxes, and function return values are randomized. The quiz involves matching the function descriptions, function syntaxes, and function return values to the correct function name. Information relating to the randomization of table cells will be displayed for three seconds, before disappearing.

On a desktop computer, table elements are selected by left-clicking the desired table cell and holding the left click in the mouse down position for one second before releasing the left click. The text inside the table cell will turn red to indicate that the one-second mouse left-click has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second left mouse-click process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second left mouse-click process on the original table cell.

To select a table element on a touchscreen device (mobile, tablet), simply touch the desired table cell and maintain the touch for one second before removing your finger from the screen. The text inside the table cell will turn red to indicate that the one-second touch has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second touch process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second touch process on the original table cell.

Normal touchscreen scrolling behaviour is exhibited by the cells with a light green background; cells without a light green background will not respond to normal touchscreen scrolling. The table is positioned in such a way that the user can also initiate touchscreen scrolling by swiping to the right or left of the table.

When a row consists of the correct function name, function description, function syntax, and function return value, the background colour of the row will change from ‘transparent’ to ‘khaki’; this provides visual feedback that the row is complete.

Once the entire table is complete, a paragraph of feedback will congratulate the user and provide the following information: date and time of quiz commencement; date and time of quiz completion; and the length of time it took the user to complete the quiz.

VIEWPORT OPTIONS:

An example of the layout designed for mobile phones
An example of the layout designed for tablets
An example of the layout designed for desktop computers

PURPOSE:

This webpage serves two purposes:

  1. It provides a reference table for the PHP mathematical functions, with information extracted and condensed from w3schools.com and php.net.
  2. It enables users to complete a quiz related to the PHP mathematical functions.

USAGE:

For each mathematical function there are four table cells of information: the function name; the function description; the function syntax; and the function return value. There are three layouts available – ‘mobile‘, ‘tablet‘, and ‘desktop‘.

Click the relevant button below to display the PHP mathematical functions reference table, sized appropriately for the desired viewport. A ‘RANDOMIZE‘ button appears above the reference table once the viewport is selected; clicking this button facilitates the commencement of a quiz.



Click the ‘RANDOMIZE‘ button to randomize the functional descriptions, the functional syntaxes, and the functional return information.



FUNCTION NAME FUNCTION DESCRIPTION FUNCTION SYNTAX FUNCTION RETURN VALUE
lcg_value()

[Combined linear congruential generator]

Returns a pseudo random number between 0 and 1. The number generated is not cryptographically secure; random_int(), random_bytes(), or openssl_random_pseudo_bytes() should be used for cryptographic purposes. lcg_value(); Returns a pseudo random float in the range 0 – 1.
log10()

[Base-10 logarithm]

Returns the base-10 logarithm of number. log10(number); Returns the float representation of the base-10 logarithm of number.
log1p()

[Returns log(1 + number), computed in such a way that is accurate even when the value of number is close to zero]

Returns log(1 + number) computed in a way that is accurate even when number is close to zero. log() might only return log(1) in this case due to lack of precision. log1p(number); Float representation of the result of log1p(number).
log()

[Natural logarithm]

If the optional base parameter is specified, log() returns logbase(number); otherwise, the natural logarithm of number is returned. log(number, base);

[numberthe value to calculate the logarithm for
basethe optional logarithmic base to use (defaults to ‘e’ and thus to the ‘natural logarithm’)]

Float return type, representing the logarithm of number to base, if given, or the natural logarithm.
max()

[Finds the highest value]

Returns the numerically highest value from the parameters provided to the function.

If the only parameter is an array, the highest value is returned; otherwise, the biggest of the parameter values is returned.

max(array_values);

OR

max(value1, value2, ...);

Returns the numerically highest value passed to the function.

If multiple values of different types evaluate as equal, the first parameter provided to the function will be returned.

If an empty array is passed, FALSE will be returned and an E_WARNING error will be emitted.

min()

[Finds the lowest value]

Returns the parameter value considered lowest according to standard comparisons.

If the only parameter is an array, the lowest value is returned; otherwise, the lowest of the parameter values is returned.

min(array_values);

OR

min(value1, value2, ...);

Returns the numerically lowest value passed to the function.

If multiple values of different types evaluate as equal, the first parameter provided to the function will be returned.

If an empty array is passed, FALSE will be returned and an E_WARNING error will be emitted.

mt_getrandmax()

[Shows the largest possible random number]

Returns the maximum value that can be returned from a call to mt_rand() without arguments, which is the maximum value that can be used for its max parameter without the result being scaled up. mt_getrandmax(); Returns an integer representation of the maximum number that can be returned by a call to rand().

Web design certified by:
Click images for proof of certification.

Exit mobile version