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:
PURPOSE:
This webpage serves two purposes:
- It provides a reference table for the PHP string functions, with information extracted and condensed from w3schools.com and php.net.
- It enables users to complete a quiz related to the PHP string functions.
USAGE:
For each string 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 string 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 |
|---|---|---|---|
nl2br()
[Inserts HTML line breaks before all newlines in a string] |
Returns string with <br/> or <br> inserted before all newlines [\r\n,\n\r,\n,\r]. | nl2br(string, is_xhtml [optional parameter, specifying whether to use XHTML-compatible line breaks or not – default is TRUE]); |
nl2br(): returns string with HTML line breaks inserted before all newlines. |
number_format()
[Format a number with grouped thousands] |
In formatting a number with grouped thousands, this function accepts 1, 2, or 4 parameters. If only 1 parameter is given, number will be formatted without decimals, but with a comma between every group of thousands. If two parameters are given, number will be formatted with decimals decimals with a dot in front, and a comma between each group of thousands. If all four parameters are given, number will be formatted with decimals decimals, dec_point instead of a dot before the decimals, and thousands_sep instead of a comma between each group of thousands. | 1- or 2-parameter syntax:number_format(number, decimals [optional parameter, with a default value of 0]);4-parameter syntax: number_format(number, decimals, dec_point, thousands_sep); |
number_format(): returns the formatted version of number. |
ord()
[Convert the first byte of a string to a value between 0 and 255] |
This function interprets the binary value of the first byte of string as an unsigned integer in the range 0-255. This function is not aware of any string encoding; it will never identify a Unicode code point in a multi-byte encoding such as UTF-8 or UTF-16. If string is in a single-byte encoding – for example, ASCII, ISO-8859, or Windows 1252 – this is equivalent to returning the position of a character in the character set’s mapping table. | ord(string); |
ord(): returns an integer between 0-255, representing the binary value of the first byte of string. |
parse_str()
[Parses the string into variables] |
Parses encoded_string as if it were the query string passed via a URL and sets variables in the current scope [or in result_array, if provided]. | parse_str(encoded_string, result_array [optional parameter, in which the parsed string variables will be stored]);
[Omission of the result_array is strongly discouraged and deprecated as of PHP 7.2.] |
parse_str(): no value is returned [void]. |
print()
[Output a string] |
This function outputs [‘prints’] arg. Parentheses are not required, since it is a language construct rather than a function. Similar to echo but only accepts a single argument, and always returns 1. |
print(arg); |
print(): always returns 1. |
printf()
[Output a formatted string] |
Produces [‘prints’] output according to format. | printf(format, args [an optional number of parameters to be output according to format]); |
printf(): returns the length of the outputted string. |
quoted_printable_decode()
[Convert a quoted printable string to an 8 bit string] |
This function – similar to imap_qprint(), except this one does not require the IMAP module to work – returns an 8-bit binary string corresponding to the decoded quoted printable string [according to RFC2045, section 6.7.] |
quoted_printable_decode(string); |
quoted_printable_decode(): returns the 8-bit binary string representation of string. |
quoted_printable_encode()
[Convert a 8 bit string to a quoted printable string] |
This function – similar to imap_8bit() except it does not require the IMAP module to work – converts an 8-bit string to a quoted printable string created according to RFC2045 Section 6.7. |
quoted_printable_encode(string); |
quoted_printable_encode(): returns the encoded string. |
quotemeta()
[Quote meta characters] |
Returns a version of string with a backslash character [\] in front of the following characters: .\+*?[^]($). Thus, it quotes the meta characters. |
quotemeta(string); |
quotemeta(): returns the string with meta characters quoted on success; FALSE if an empty string is passed to the function. |
setlocale()
[Sets locale information] |
This function sets locale information. | With locale as string:setlocale(category, locale_string [1 or more optional parameters to try as locale settings until success]);With locale as array: setlocale(category, locale_array [each array element will be used in an attempt to set the locale until one is successful]);
[category is a named constant specifying the category of the functions affected by the locale setting. The following seven named constants are permissible: LC_ALL; LC_COLLATE; LC_CTYPE; LC_MONETARY; LC_NUMERIC; LC_TIME; or LC_MESSAGES. |
setlocale(): returns the new current locale on success, or FALSE if the locale functionality is not implemented on your platform, the specified locale does not exist, or the category name is invalid. An invalid category name also causes a WARNING message. |
sha1_file()
[Calculate the sha1 hash of a file] |
Calculates and returns the sha1 hash of the file specified by filename using the US Secure Hash Algorithm 1. The hash is a forty-character hexadecimal number. | sha1_file(filename, raw_output [optional parameter, defaults to FALSE]);
[If raw_output is set to TRUE the digest is returned in raw binary format with a length of twenty.] |
sha1_file(): returns the sha1 hash of the file specified by filename on success; FALSE on failure. |

