Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the following is the correct syntax for an if statement? if ($aVariable

ID: 3728510 • Letter: W

Question

Which of the following is the correct  syntax for an if statement?


if ($aVariable == 1)()

if ($aVariable == 1);

if $aVariable == 1

if ($aVariable == 1)

 

Question 2

An if statement can execute multiple lines of PHP code if they are 

are within a command { ... } block

are excluded from the PHP code

are within an always false if statement

are within a code segment /* ... */

 


Question 3

Which is the correct PHP syntax for else: 

else { echo "the else statement"; }

else / { echo "the else statement"; }

else - echo "the else statement"

else ; { echo "the else statement"; }

 


Question 4

Each time a loop run through the code, it's called a 

deduplication

iteration

looping

recurrence

 


Question 5

Which while loop syntax is correct? 

while $i < 100 { }

while ($i < 100) { }

while ($i < 100; i++) { }

while $i < 100 ...

 


Question 6

The for statement can initialize a counter.

True

False

 


Question 7

The do ... while statement will always execute at least once.

True

False

 


Question 8

The while statement will execute a series of statements as long as a given conditional expression evaluates to FALSE.

True

False

 


Question 9

A if . . . else statement allows a program to make decisions about what statements to execute.

 

True

False

 


Question 10

The if/else statement will contain at least one condition statement to make the decision to run one block of code and skip over another block of code. 

True

False

Explanation / Answer

ANswer1: if ($aVariable == 1)

if statement syntax is if(condition).

Answer2:

An if statement can execute multiple lines of PHP code if they are

are within a command { ... } block

<?php
if ($a > $b) {
  echo "a is greater than b";
  $b = $a;
}
?>

Answer3: the correct PHP syntax for else is else { echo "the else statement"; }

if (condition) {
  code ;
} else {
   code ;
}

Answer4:  Each time a loop run through the code, it's called a iteration

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote