Chapter Solutions 4-6 - Chapter 4 Answers 1. A(n) _ allows...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 4 Answers 1. A(n) _____ allows you to treat a related group of PHP commands as a single unit. a. statement b. variable c. function d. event 2. Functions must contain parameters. True or False? 3. Explain how to use a return statement to return a value to a statement that calls a function. A return statement is a statement that returns a value to the statement that called the function. You use the return keyword within a function body to return a value or variable to a calling statement. 4. A variable that is declared outside a function is called a(n) _____ variable. a. local b. class c. program d. global 5. A local variable must be declared _____. a. before a function b. after a function c. within the braces of a function definition d.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
7. Which of the following is the correct syntax for an if statement? a. if ($MyVariable == 10); echo “Your variable is equal to 10.”; b. if $MyVariable == 10 echo “Your variable is equal to 10.”; c. if ($MyVariable == 10) echo “Your variable is equal to 10.”; d. if ($MyVariable == 10), echo "Your variable is equal to 10."; 8. An if statement can include multiple statements provided that they _____. a. execute after the if statement’s closing semicolon b. are not contained within a command block c. do not include other if statements d. are contained within a command block 9. Explain how to construct an if statement that executes multiple statements. You can use a command block to construct a decision-making structure using multiple if statements. A command block is a group of statements contained within a set of braces, similar to the way function statements are contained within a set of braces. Each command block must have an opening brace ( { ) and a closing brace ( } ). If a command block is missing either the opening or closing brace, an error occurs. 10. Which is the correct syntax for an else clause? a. else (echo “Printed from an else clause.”; b.
Background image of page 2
11. The switch statement controls program flow by executing a specific set of statements, depending on _____. a. the result of an if. ..else statement b. the version of PHP being executed c. whether an if statement executes from within a function d. the value returned by a conditional expression 12. Decision-making structures cannot be nested. True or False? 13. When the value returned by a switch statement expression does not match a case label, the _____
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

Chapter Solutions 4-6 - Chapter 4 Answers 1. A(n) _ allows...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online