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 |
|---|---|---|---|
sha1()
[Calculate the sha1 hash of a string] |
This function calculates the sha1 hash of string, using the US Secure Hash Algorithm 1. | sha1(string, raw_output [optional parameter with a default value of FALSE]);
[If raw_output is set to TRUE, the sha1 digest is instead returned in raw binary format with a length of 20; otherwise the returned value is a 40-character hexadecimal number.] |
sha1(): returns the sha1 hash as a string. |
similar_text()
[Calculate the similarity between two strings] |
This function calculates the similarity of string_1 and string_2 [two ‘texts’]. | similar_text(string_1, string_2, percentage [optional parameter – passing a reference as the third parameter stores the similarity in percent, by dividing the result of similar_text() by the average length of the given strings (similar_text()/((string_1_length + string_2_length)/2) * 100)]);
[The number of matching characters is calculated by finding the longest first common substring, and then doing this for the prefixes and the suffixes, recursively. The lengths of all common substrings are added.] |
similar_text(): returns the number of matching chars in both strings. |
soundex()
[Calculate the soundex key of a string] |
Calculates the soundex key of string. Words pronounced similarly produce the same soundex key, and can therefore be used to simplify searching databases where you know the pronunciation but not the spelling. This implementation of the soundex function returns a string 4 characters long, starting with a letter. | soundex(string); |
soundex(): returns the soundex key as string. |
sprintf()
[Return a formatted string] |
This function returns a string produced according to format_string. | sprintf(format_string, args... [optional parameters that will be formatted according to format_string]);
[The format_string is composed of zero or more directives: ordinary characters that are copied directly to the result and conversion specifications, each of which results in fetching its own parameter. Each conversion specification contains a percentage sign followed by one or more of the following elements, in sequence: sign specifier; padding specifier; alignment specifier; width specifier; precision specifier; and a type specifier.] |
sprintf(): returns a string produced according to format_string on success; FALSE on failure. |
sscanf()
[Parses input from a string according to a format] |
This function reads [‘scans’] from string and interprets it according to format. Any whitespace in format [even a tab \t] matches any whitespace in string. | sscanf(string, format, args... [optionally pass in variables by reference that will contain the parsed values]); |
sscanf(): if only two parameters were present, the values parsed will be returned as an array. If optional parameters are passed, the function will return the number of assigned values. If more substrings are expected in format than are available within string, -1 will be returned. |
str_getcsv()
[Parse a CSV string into an array] |
This function parses input_string for fields in CSV format and returns an array containing the fields read. Take care with locale settings when using this function – strings in one-byte encodings may be read incorrectly if LC_CTYPE is set to en_US.UTF-8, for example. | str_getcsv(input_string, delimiter [optional single-character parameter, default is “,“], enclosure [optional single-character parameter, default is ‘“‘], escape_character [optional single-character parameter, default is “\“]); |
str_getcsv(): returns an indexed array containing the fields read. |
str_ireplace()
[Case-insensitive version of |
This function returns a string or an array with all case-insensitive occurrences of search in subject replaced with the given replace value. | str_ireplace(search, replace, subject, count [optional parameter – if passed, this will be set to the number of replacements performed]);
[Search and replace rules: if search and replace are arrays, a value is taken from each array and used to search-and-replace on subject; if replace has fewer values than search, an empty string is used for the rest of replacement values; if search is an array and replace is a string, then this replacement string is used for every value of search; if search or replace are arrays, their elements are processed first to last.] |
str_ireplace(): returns a string or an array of replacements. |
str_pad()
[Pad a string to a certain length with another string] |
This function returns input_string padded on the left, the right, or on both sides to the specified pad_length. If pad_string is not supplied, input_string is padded with spaces; otherwise it is padded with characters from pad_string up to the limit. | str_pad(input_string, pad_length, pad_string [optional parameter – default is whitespace “ “], pad_type [optional parameter – default value is STR_PAD_RIGHT]);
[If pad_length is negative, less than or equal to the length of input_string, no padding takes place and input_string will be returned. The pad_string may be truncated if the required number of padding characters cannot be evenly divided by the pad_string‘s length. pad_type can be any of the following values: STR_PAD_RIGHT; STR_PAD_LEFT; or STR_PAD_BOTH] |
str_pad(): returns the padded string. |
str_repeat()
[Repeat a string] |
This function returns input_string repeated multiplier times. | str_repeat(input_string, multiplier);
[multiplier must be greater than or equal to 0. If 0, an empty string will be returned.] |
str_repeat(): returns input_string repeated multiplier times. |
str_replace()
[Replace all occurrences of the search string with the replacement string] |
This function returns a string or an array with all case-sensitive occurrences of search in subject replaced with the given replace value. | str_replace(search, replace, subject, count [optional parameter – if present, it will be set to the number of replacements performed]);
[The same search-and-replace rules apply for this function as for |
str_replace(): returns a string or an array with the replaced values. |
str_rot13()
[Perform the rot13 transform on a string] |
This function performs the ROT13 encoding on string and returns the resulting string. The ROT13 encoding simply shifts every letter by 13 places in the alphabet; non-alpha characters are left untouched. Since encoding and decoding are done by the same function, passing an encoded string as argument will return the original version. | str_rot13(string); |
str_rot13(): returns the ROT13 version of string. |
