PHP MCQ Quiz Hub

PHP Mcq – Functions

Choose a topic to test your knowledge and improve your PHP skills

Type Hinting was introduced in which version of PHP?





✅ Correct Answer: 2

What will be the output of the following PHP code? <?php function calc($price, $tax="") { $total = $price + ($price * $tax); echo "$total"; } calc(42); ?>





✅ Correct Answer: 3

Which of the following are valid function names? i) function() ii) €() iii) .function() iv) $function()





✅ Correct Answer: 2

What will be the output of the following PHP code? <?php function a() { function b() { echo 'I am b'; } echo 'I am a'; } a(); a(); ?>





✅ Correct Answer: 1

What will be the output of the following PHP code? <?php function a() { function b() { echo 'I am b'; } echo 'I am a'; } b(); a(); ?>





✅ Correct Answer: 3

What will be the output of the following PHP code? <?php $op2 = "blabla"; function foo($op1) { echo $op1; echo $op2; } foo("hello"); ?>





✅ Correct Answer: 3

A function in PHP which starts with __ (double underscore) is known as __________





✅ Correct Answer: 4

What will be the output of the following PHP code? <?php function foo($msg) { echo "$msg"; } $var1 = "foo"; $var1("will this wo





✅ Correct Answer: 4

Which of the following PHP functions accepts any number of parameters?





✅ Correct Answer: 2

Which of the following PHP functions can be used for generating unique ids?





✅ Correct Answer: 1

Which one of the following functions can be used to compress a string?





✅ Correct Answer: 4

What will be the output of the following PHP code? <?php echo chr(52); ?>





✅ Correct Answer: 4

What will be the output of the following PHP code? <?php echo ord ("hi"); ?>





✅ Correct Answer: 3

What will be the output of the following PHP code? <?php $str = "Hello World"; echo wordwrap($str,5,"<br> "); ?>





✅ Correct Answer: 2

What will be the output of the following PHP code? <?php echo ucwords("i love my country"); ?>





✅ Correct Answer: 4

What will be the output of the following PHP code? <?php echo lcfirst("welcome to India"); ?>





✅ Correct Answer: 1