Home
MCQS
PHP MCQ Quiz Hub
PHP Mcq – Functions
Choose a topic to test your knowledge and improve your PHP skills
1. Type Hinting was introduced in which version of PHP?
PHP 4
PHP 5
PHP 5.3
6
2. What will be the output of the following PHP code? <?php function calc($price, $tax="") { $total = $price + ($price * $tax); echo "$total"; } calc(42); ?>
Error
0
42
84
3. Which of the following are valid function names? i) function() ii) €() iii) .function() iv) $function()
Only i)
Only ii)
i) and ii)
iii) and iv)
4. 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(); ?>
I am a
I am bI am a
Error
I am a Error
5. 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(); ?>
I am b
I am bI am a
Error
I am a Error
6. What will be the output of the following PHP code? <?php $op2 = "blabla"; function foo($op1) { echo $op1; echo $op2; } foo("hello"); ?>
helloblabla
Error
hello
helloblablablabla
7. A function in PHP which starts with __ (double underscore) is known as __________
Magic Function
Inbuilt Function
Default Function
User Defined Function
8. What will be the output of the following PHP code? <?php function foo($msg) { echo "$msg"; } $var1 = "foo"; $var1("will this wo
Error
$msg
0
Will this work
9. Which of the following PHP functions accepts any number of parameters?
func_get_argv()
func_get_args()
get_argv()
get_argc()
10. Which of the following PHP functions can be used for generating unique ids?
uniqueid()
id()
md5()
mdid()
11. Which one of the following functions can be used to compress a string?
zip_compress()
zip()
compress()
gzcompress()
12. What will be the output of the following PHP code? <?php echo chr(52); ?>
1
2
3
4
13. What will be the output of the following PHP code? <?php echo ord ("hi"); ?>
106
103
104
209
14. What will be the output of the following PHP code? <?php $str = "Hello World"; echo wordwrap($str,5,"<br> "); ?>
Hello World
Hello World
Hell o wo rld
world
15. What will be the output of the following PHP code? <?php echo ucwords("i love my country"); ?>
I love my country
i love my Country
I love my Country
I Love My Country
16. What will be the output of the following PHP code? <?php echo lcfirst("welcome to India"); ?>
welcome to India
welcome to india
Welcome to India
Welcome to india
Submit