Q.1
What is PHP?
  • a) PHP is an open-source programming language
  • b) PHP is used to develop dynamic and interactive websites
  • c) PHP is a server-side scripting language
  • d) All of the mentioned
Q.2
Who is the father of PHP?
  • a) Drek Kolkevi
  • b) Rasmus Lerdorf
  • c) Willam Makepiece
  • d) List Barely
Q.3
What does PHP stand for?
  • a) PHP stands for Preprocessor Home Page
  • b) PHP stands for Pretext Hypertext Processor
  • c) PHP stands for Hypertext Preprocessor
  • d) PHP stands for Personal Hyper Processor
Q.4
Which of the following is the correct syntax to write a PHP code?
  • a) <?php ?>
  • b) < php >
  • c) < ? php ?>
  • d) <? ?>
Q.5
Which of the following is the correct way to add a comment in PHP code?
  • a) #
  • b) //
  • c) /* */
  • d) All of the mentioned
Q.6
Which of the following is the default file extension of PHP files?
  • a) .php
  • b) .ph
  • c) .xml
  • d) .html
Q.7
How to define a function in PHP?
  • a) functionName(parameters) {function body}
  • b) function {function body}
  • c) function functionName(parameters) {function body}
  • d) data type functionName(parameters) {function body}
Q.8
What will be the output of the following PHP code? <?php $x =$y =if ($x > $y && 1|| print "PHP MCQ" ; else print "Welcome to Sanfoundry"; ?>
  • a) no output
  • b) Welcome to Sanfoundry
  • c) 1000 PHP MCQ
  • d) error
Q.9
Which is the right way of declaring a variable in PHP?
  • a) $3hello
  • b) $_hello
  • c) $this
  • d) $5_Hello
Q.10
What will be the output of the following PHP program? <?php $fruits = array ("apple", "orange", array ("pear", "mango"),"banana"); echo (count($fruits, 1)); ?>
  • a) 6
  • b) 5
  • c) 4
  • d) 3
Q.11
What will be the output of the following PHP program? <?php function multi($num) { if ($num == echo "I Wonder"; if ($num == echo "Which One"; if ($num == echo "Is The"; if ($num == echo "Correct Answer"; } $can = stripos("I love php, I love php too!","PHP"); multi($can); ?>
  • a) Correct Answer
  • b) Is The
  • c) I Wonder
  • d) Which One
Q.12
Which of the following PHP functions can be used for generating unique ids?
  • a) md5()
  • b) uniqueid()
  • c) mdid()
  • d) id()
Q.13
In the following PHP program, what is/are the properties? <?php class Example { public $name; function Sample() { echo "Learn PHP @ Sanfoundry"; } } ?>
  • a) function sample()
  • b) echo “This is an example”;
  • c) public $name;
  • d) class Example
Q.14
What will be the output of the following PHP code? <?php define("GREETING", "PHP is a scripting language"); echo $GREETING; ?>
  • a) $GREETING
  • b) no output
  • c) PHP is a scripting language
  • d) GREETING
Q.15
A function in PHP which starts with __ (double underscore) is known as __________
  • a) Default Function
  • b) User Defined Function
  • c) Inbuilt Function
  • d) Magic Function
Q.16
How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.
  • a) 10
  • b) 7
  • c) 8
  • d) 9
Q.17
Which of the following web servers are required to run the PHP script?
  • a) Apache and PHP
  • b) IIS
  • c) XAMPP
  • d) Any of the mentioned
Q.18
What will be the output of the following PHP code snippet? <?php $url = "[email protected]"; echo ltrim(strstr($url, "@"),"@"); ?>
  • a) [email protected]
  • b) [email protected]
  • c) [email protected]
  • d) sanfoundry.com
Q.19
Which of the following PHP functions can be used to get the current memory usage?
  • a) memory_get_usage()
  • b) memory_get_peak_usage()
  • c) get_peak_usage()
  • d) get_usage()
Q.20
Which one of the following PHP function is used to determine a file’s last access time?
  • a) filetime()
  • b) fileatime()
  • c) fileltime()
  • d) filectime()
0 h : 0 m : 1 s