Chapter

Solution to Question 4-1

Code that performs a task.

Solution to Question 4-2 An operator.

Solution to Question 4-3

An operator combines simple expressions into more complex expressions. It does so by creating relationships between the simple expressions that can then be evaluated.

Solution to Question 4-4 An operator.

Solution to Question 4-5

An operator that combines two expressions into a more complex single expression.

Solution to Question 4-6

An operator that takes three operands.

Solution to Question 4-7

No—they take only numbers.

Solution to Question 4-8

It's an array, integer, or string.

Solution to Question 4-9

Yes—you'll end up with the wrong operator.

Solution to Question 4-10

It checks whether a variable is set.

Solution to Question 4-11

The switch statement is written as follows:

switch ($action) { case "add": $x = $x+y; break; case "subtract": $x = $x-y; break; case "multiply": $x = $x*$y; break; case "divide": $x = $x/$y; break;

Solution to Question 4-12

It tells PHP not to execute cases other than the matching case.

Solution to Question 4-13

The loop is written as follows: <?php for ($num = 10; $num >= 1; $num&#8722;&#8722;) { print "$num<br>";

Solution to Question 5-1

This isn't a valid function. It's missing the parentheses; furthermore, it's bad style to mix functions with your main code.

Solution to Question 5-2

To define the toast function with a parameter: <?php function toast( $minutes ){

Solution to Question 5-3

To call toast with 5 as the minutes parameter:

Solution to Question 5-4

When you are using include() and a file can't be found, only a warning issues. However, when you are using require(), a missing file causes a fatal error that terminates the execution of the script.

Solution to Question 5-5 A method.

Was this article helpful?

0 0

Post a comment