Chapter 2: How to code a PHP application

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following is not a compound assignment operator in PHP?

!=

How many times will the for loop that follows be executed? $years = 25; for ($i = 1; $i < $years; $i++) { $future_value = ($future_value + ($future_value * $interest_rate)); }

24

After the if statement that follows is executed, what will the value of $discount_amount be? $discount_amount; $order_total = 200; if ($order_total > 200) { $discount_amount = $order_total * .3; } else if ($order_total > 100) { $discount_amount = $order_total * .2; } else { $discount_amount = $order_total * .1; }

40

After the code that follows is executed, what will the value of $units_per_store be? $units = 30; $stores = 4; $units_per_store = intdiv($units, $stores);

7

Which character is used to separate the original URL from the parameters that are appended to it?

?

________________ are used in PHP to perform mathematical calculations, such as addition.

Arithmetic operators

Which method of the form appends values to the URL to pass data?

GET

________________ operators are used for combining conditional expressions.

Logical

Assigning ________________ to a variable indicates the variable does not contain a usable value.

NULL

Which method of the form passes data without appending the parameters to the URL?

POST

A ________________ contains a value that does not change during the course of program execution.

constant

In the code that follows, if $error_message isn't empty if ($error_message != '') { include('index.php'); exit(); }

control is passed to a page named index.php that's in the current directory

You can use the htmlspecialchars() function to protect against ________________.

cross-site scripting (XSS) attacks

To print a variable with the echo statement, you simply pass the variable name to the echo statement. For example:

echo $VotingAge;

The equality operator consists of two ________________ signs and performs a different function than the one performed by the assignment operator that consists of a single sign.

equal

It's considered a best practice to always use the ________________ function when you get values from a superglobal array.

filter_input()

The order of precedence for arithmetic expressions causes

increment operations to be done first

A(n) ________________ is a positive or negative number with no decimal places.

integer

When double quotes are used to assign values to string variables, the PHP interpreter must check the entire string to see if it contains any variables that need to be inserted into the string. This process is called:

interpolation

A PHP variable name

is case-sensitive

Which attribute of a form element determines how the data is passed to a file?

method

The ________________ operator divides one operand by another operand and returns the remainder.

modulus

What is the concatenation operator in PHP?

period(.)

How many data types are used by PHP?

six

To round and format the value of a variable named $number to 3 decimal places and store it in a variable named $number_formatted, you code

$number_formatted = number_format($number, 3);

Which character is used to separate parameters that are appended to a URL?

&

How many times will the while loop that follows be executed? $months = 5; $i = 1; while ($i > $months) { $futureValue = $futureValue * (1 + $monthlyInterestRate); $i = $i+1; }

0

If $total_months has a value of 13, what does $message contain after this if statement is executed? $years = $total_months / 12; $years = number_format($years); $months = $total_months % 12; if ( $years == 0 ) { $message = $months . " months"; } else if ( $months == 0 ) { $message = $years . " years"; } else { $message = $years . " years, and " . $months . " months"; }

1 years, and 1 month

What will $future_value contain after the for loop that follows has been executed one time? $years = 10; $annual_rate = 10; $future_value = 1000; $annual_rate = $annual_rate / 100; for ( $i = 1; $i <= $years; $i++ ) { $future_value = $future_value * (1 + $annual_rate); }

1100


Set pelajaran terkait

PNL210 - practical nursing lab (week 1-5)

View Set

Psych 110 Study questions Exam 1

View Set

social psychology - exam #2 (ch. 4, 6, 7)

View Set

II Chapter 9 - Web & Database Attacks

View Set

Therapeutic Exercise: Energy Systems and Assessment

View Set