Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
PHP Basics IICBIS 4210
Quiz 2
• This quiz is on D2L. Please take it quickly. When you are finished, bring up your composition book to be checked off today.
Helix
1. How do you login?
2. How do you make a new project and repository?
3. How do you push your code to the repository?
4. How do you turn in your code?
PHP Arithmetic Operators
PHP Math Functions
• https://www.w3schools.com/Php/php_ref_math.asp
PHP Assignment Operators
PHP Comparison Operators
PHP String Operators
PHP Logical Operators
Get the Length of a String
Count the Number of Words in a String
Reverse a String
Replace Text Within a String
Manipulating Strings
// use this to count the number of characters
strlen($variable)
// use this to trim any spaces off front or back of input
trim($variable)
if (strlen(trim($_POST[‘zipcode’])) != 5) {
echo “Please enter a zip code that is 5 digits long”;
}
Changing Case
//upper case the first letter of each word
ucwords($var1)
//lower case the whole word
strtolower($var1)
All the Functions
• https://www.w3schools.com/Php/php_ref_string.asp
Inclass• Write a PHP program that computes the total cost of this restaurant meal:
two hamburgers @ $4.95 eachone chocolate milkshake @ $1.95one litter of cola @ .85
• Sales tax is 7.5%
• You left a pre-tax tip of 16%
Now format this as a bill.
• For each item, print the price, quantity and total costs.
• Print the pre-tax food and drink total, the post-tax total, and the total with tax and tip.