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 |
|---|---|---|---|
substr_count()
[Count the number of substring occurrences] |
This function returns the number [‘count’] of times the needle substring occurs in the haystack string. needle is case-sensitive. | substr_count(haystack, needle, offset [optional parameter with a default value of 0], length [optional parameter]);
[offset specifies the position at which to start counting. If negative, the comparison begins at offset characters from the end of the string. length specifies the maximum length after offset to search for the needle. A WARNING is output if offset plus length is greater than the haystack length. A negative length counts from the end of haystack.] |
substr_count(): returns an integer representation of the number of occurrences of needle within haystack. |
substr_replace()
[Replace text within a portion of a string] |
This function replaces a copy of string delimited by the start and optional length parameters [thus, a ‘substring’] with the replacement string. | substr_replace(string, replacement, start, length [optional parameter, with a default value of strlen(string)]);
[string represents the input string. An array of strings can be provided; in this case, the replacements will occur on each string in turn. replacement, start, and length may be provided as either scalar values or as arrays (whereby the corresponding array element will be used for each input string). |
substr_replace(): the result string is returned. If string is an array, then an array is returned. |
substr()
[Return part of a string] |
This function returns the portion [‘substring’] of string specified by the start and length parameters. | substr(string, start, length [optional parameter]);
[string represents the input string; must be one character or longer. |
substr(): returns the extracted part of string [the ‘substring’]; FALSE on failure, or an empty string. |
trim()
[Strip whitespace (or other characters) from the beginning and end of a string] |
This function returns a string with whitespace stripped [‘trimmed’] from the beginning and end of string. If character_mask is unspecified, trim() will strip the following characters: an ordinary space; a tab; a new line; a carriage return; the NUL-byte; and the vertical tab. |
trim(string, character_mask [optional parameter, with a default value of “\t\n\r\0\x0B”]);
[Further characters can be specified in the character_mask parameter. With .., a range of characters can be specified.] |
trim(): returns the trimmed string. |
ucfirst()
[Make a string’s first character uppercase] |
This function returns a string with the first character of string capitalized [‘uppercased’], if that character is alphabetic. ‘Alphabetic’ is determined by the current locale; in the default C locale, characters such as umlaut-a will not be capitalized. | ucfirst(string); |
ucfirst(): returns the resulting string, after its first character has been uppercased if it is suitably ‘alphabetic’. |
ucwords()
[Uppercase the first character of each word in a string] |
This function returns a string with the first character of each word in string capitalized [‘uppercased’], if that character is ‘alphabetic’. A ‘word’ is defined as any string of characters that is immediately after any character listed in the delimiters parameter. | ucwords(string, delimiters [optional parameter, with a default value of " \t\r\n\f\v"]);
[The optional delimiters parameter contains the word separator characters. By default these are: space; horizontal tab; carriage return; form-feed; newline; and vertical tab.] |
ucwords(): returns the modified string, after the first character of all words have been uppercased if suitably ‘alphabetic’. |
vfprintf()
[Write a formatted string to a stream] |
This function writes [‘prints’] a string produced according to format to the stream resource specified by handle. Operates as fprintf() but accepts an array of args, rather than a variable number of arguments. |
vfprintf(handle, format, args);
[See |
vfprintf(): returns the length of the outputted string. |
vprintf()
[Output a formatted string] |
This function displays [‘prints’] array values as a string formatted according to format. Operates as printf() but accepts an array of arguments, rather than a variable number of arguments. |
vprintf(format, args);
[See |
vprintf(): returns the length of the outputted string. |
vsprintf()
[Return a formatted string] |
vsprintf() operates as sprintf() but accepts an array of arguments, rather than a variable number of arguments. |
vsprintf(format, args);
[See |
vsprintf(): returns the array values as a string formatted according to format. |
wordwrap()
[Wraps a string to a given number of characters] |
This function wraps a string [‘word’] to a given number of characters using a string break character. | wordwrap(string, width [optional parameter, default value = 75], break [optional parameter, default value = "\n"], cut [optional parameter, default value = FALSE]);
[If cut is set to TRUE, the string is always wrapped at or before width. When FALSE, the function does not split the word even if it is wider than width.] |
wordwrap(): returns the given string [‘word’] wrapped at the specified length. |

