$a = ?;
$b = ?;
$c = ?;
if($a) {
if($b && !$c) {
echo "Goodbye Cruel World!";
} else if(!$b && !$c) {
echo "Nothing here";
}
} else {
if(!$b){
if(!$a && (!$b && $c)) {
echo "Hello, World!";
} else {
echo "Goodbye World!";
}
} else {
echo "Not quite.";
}
}
?> - Ответ: D) False, False, True"> PHP Test online - 7. Which values should be assigned to the variables $a, $b and $c in order for the following script to display the string Hello, World!?<br><br><?php<br>$string = "Hello, World!";<br>$a = ?;<br>$b = ?;<br>$c = ?;<br>if($a) {<br>if($b && !$c) {<br>echo "Goodbye Cruel World!";<br>} else if(!$b && !$c) {<br>echo "Nothing here";<br>}<br>} else {<br>if(!$b){<br>if(!$a && (!$b && $c)) {<br>echo "Hello, World!";<br>} else {<br>echo "Goodbye World!";<br>}<br>} else {<br>echo "Not quite.";<br>}<br>}<br>?> - Верный ответ: D) False, False, True

7. Which values should be assigned to the variables $a, $b and $c in order for the following script to display the string Hello, World!?

<?php
$string = "Hello, World!";
$a = ?;
$b = ?;
$c = ?;
if($a) {
if($b && !$c) {
echo "Goodbye Cruel World!";
} else if(!$b && !$c) {
echo "Nothing here";
}
} else {
if(!$b){
if(!$a && (!$b && $c)) {
echo "Hello, World!";
} else {
echo "Goodbye World!";
}
} else {
echo "Not quite.";
}
}
?>


Вариант ответа 1 - A) False, True, False

Вариант ответа 2 - B) True, True, False

Вариант ответа 3 - C) False, True, True

Вариант ответа 4 - D) False, False, True

Вариант ответа 5 - E) True, True, True


Комментарий: Following the logic of the conditions, the only way to get to the Hello, World! string is in the else condition of the first if statement. Thus, $a must be False. Likewise, $b must be False. The final conditional relies on both previous conditions ($a and $b) being False, but insists that $c be True (Answer D).

Комментарии

Имя пользователяТекст комментарияВведите код