The code will throw a compilation error.

, 2.

The code will compile successfully but will not print anything.

, 3.

The code will compile successfully and will print the following:

array(3) {

[0]=>

NULL

[1]=>

NULL

[2]=>

NULL

}


, 4.

The code will compile successfully and will print the following:array(3) {

[0]=>

Five

[1]=>

Six

[2]=>

Seven

}


">
MCQs > IT & Programming > PHP 5 > Which is correct about the following snippet? function example() { foreach (range(5, 7) as $a){yield; } } var_dump(iterator_to_array(example())); ?>

PHP 5 MCQs

Which of the given statements is correct about the following PHP 7.1 code snippet?

function example() {

foreach (range(5, 7) as $a){yield;

}

}

var_dump(iterator_to_array(example()));

?>

Answer

Correct Answer:

The code will compile successfully and will print the following:

array(3) {

[0]=>

NULL

[1]=>

NULL

[2]=>

NULL

}


Explanation:

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

PHP 5 Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

PHP 5 Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it