The workshop is designed to help you anticipate possible questions, review what you've learned, and begin learning how to put your knowledge into practice.
What conversion specifier would you use with printf() to format an integer as a double? Indicate the full syntax required to convert the integer 33.
You use the conversion specifier f to format an integer as a double:
How would you pad the conversion you effected in question 1 with zeros so that the part before the decimal point is four characters long?
You can pad the output from printf() with the padding specifier that is, a space or a zero followed by a number representing the number of characters you want to pad by.
How would you specify a precision of two decimal places for the floating-point number you have been formatting in the previous questions?
The precision specifier consists of a dot (.) followed by a number representing the precision you want to apply. It should be placed before the conversion specifier:
What function would you use to extract a substring from a string?
The substr() function extracts and returns a substring.
How might you remove whitespace from the beginning of a string?
The ltrim() function removes whitespace from the start of a string.
How would you break up a delimited string into an array of substrings?
The explode() function splits up a string into an array.
Write an SQL query to find the starting position of a substring "grape" in a string "applepearbananagrape".
SELECT LOCATE('grape', 'applepearbananagrape');
Write a query that selects the last 5 characters from the string "applepearbananagrape".
SELECT RIGHT("applepearbananagrape", 5);
Create a feedback form that accepts a user's full name and an email address. Use case conversion functions to capitalize the first letter of each name the user submits and print the result back to the browser. Check that the user's email address contains the @ symbol and print a warning otherwise.
Create an array of doubles and integers. Loop through the array converting each element to a floating-point number with a precision of 2. Right-align the output within a field of 20 characters.
Using both PHP and MySQL, practice using functions within functions, such as making case changes on substrings and concatenating strings.