Which of the following web servers are required to run the PHP script?
1.Apache and PHP
2.IIS
3.XAMPP
4.Any of the mentioned
How to define a function in PHP?
1.functionName(parameters) {function body}
2.function {function body}
3.function functionName(parameters) {function body}
4.data type functionName(parameters) {function body}
What will be the output of the following PHP code snippet? <?php $url = "phpmcq@sanfoundry.com"; echo ltrim(strstr($url, "@"),"@"); ?>
1.phpmcq@sanfoundry.com
2.php@sanfoundry.com
3.phpmcq@
4.sanfoundry.com
What will be the output of the following PHP code? <?php $x = 10; $y = 20; if ($x > $y && 1||1) print "1000 PHP MCQ" ; else print "Welcome to Sanfoundry"; ?>
1.no output
2.Welcome to Sanfoundry
3.1000 PHP MCQ
4.error
What will be the output of the following PHP code? <?php function constant() { define("GREETING", "Welcome to Sanfoundry",true); echo greeting; } ?>
1.GREETING
2.Welcome to Sanfoundry
3.ERROR
4.greeting
What will be the output of the following PHP program? <?php function multi($num) { if ($num == 3) echo "I Wonder"; if ($num == 7) echo "Which One"; if ($num == 8) echo "Is The"; if ($num == 19) echo "Correct Answer"; } $can = stripos("I love php, I love php too!","PHP"); multi($can); ?>
1.Correct Answer
2.Is The
3.I Wonder
4.Which One
Which of the following is the default file extension of PHP files?
1..php
2..ph
3..xml
4..html
Which of the looping statements is/are supported by PHP? i) for loop ii) while loop iii) do-while loop iv) foreach loop
1.Only iv)
2.i) and ii)
3.i), ii) and iii)
4.i), ii), iii) and iv)
Which PHP function displays the web page’s most recent modification date?
1.getlastmod()
2.get_last_mod()
3.lastmod()
4. last_mod()
Which PHP function displays the web page’s most recent modification date? a)
1.getlastmod()
2.get_last_mod()
3.lastmod()
4. last_mod()
. In the following PHP program, what is/are the properties? <?php class Example { public $name; function Sample() { echo "Learn PHP @ Sanfoundry"; } } ?>
1. function sample()
2.echo “This is an example”;
3.public $name;
4.class Example
A function in PHP which starts with __ (double underscore) is known as __________
1.Default Function
2.User Defined Function
3. Inbuilt Function
4.Magic Function
If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
1.1
2.5
3.12
4.Error
The developers of PHP deprecated the safe mode feature as of which PHP version?
1.PHP 5.3.1
2. PHP 5.3.0
3.PHP 5.1.0
4.PHP 5.2.0
What does PDO stand for?
1.PHP Database Orientation
2.PHP Data Orientation
3.PHP Data Object
4.PHP Database Objec
What does PHP stand for?
1.PHP stands for Preprocessor Home Page
2.PHP stands for Pretext Hypertext Processor
3.PHP stands for Hypertext Preprocessor
4.PHP stands for Personal Hyper Processor
What is PHP?
1.PHP is an open-source programming language
2.PHP is used to develop dynamic and interactive websites
3.PHP is a server-side scripting language
4.All of the mentioned
What will be the output of the following PHP code? <?php $x = 4; $y = 3 $z = 1; $z = $z + $x + $y; echo "$z"; ?>
1.15
2.8
3.1
4.$z
What will be the output of the following PHP code? <?php $x = 5; $y = 10; function fun() { $y = $GLOBALS['x'] + $GLOBALS['y']; } fun(); echo $y; ?>
1.5
2.10
3.15
4.Error
What will be the output of the following PHP code? <?php define("GREETING", "PHP is a scripting language"); echo $GREETING; ?>
1.$GREETING
2.no output
3.PHP is a scripting language
4.GREETING
What will be the output of the following PHP program? <?php $a = "$winner"; $b = "/$looser"; echo $a,$b; ?>
1. /
2.$looser
3.$looser/
4.$winner/$looser
What will be the output of the following PHP program? <?php $a = 100; if ($a > 10) printf("PHP Quiz"); else if ($a > 20) printf("PHP MCQ"); else if($a > 30) printf("PHP Program"); ?>
1.PHP Quiz PHP MCQ PHP Program
2.PHP Quiz
3.PHP MCQ
4.No output
What will be the output of the following PHP program? <?php $fruits = array ("apple", "orange", array ("pear", "mango"),"banana"); echo (count($fruits, 1)); ?>
1.6
2.5
3.4
4.3
What will be the output of the following PHP program? <?php $i = 5; while (--$i > 0 && ++$i) { print $i; } ?>
1. 555555555…infinitely
2.54321
3.Error
4.5
What will be the output of the following PHP program? <?php $mcq = 1; switch(print $mcq) { case 2: print "HTML"; break; case 1: print "CSS"; break; default: print "JavaScript"; } ?>
1.error
2.1HTML
3.1JavaScript
4.1CSS
What will be the output of the following PHP program? <?php $php = array("Array", "Function", "Strings", "File"); echo pos($php); ?>
1.Function
2.File
3.Strings
4.Array
What will be the output of the following PHP program? <?php $php = array("Array", "Function", "Strings", "File"); echo pos($php); ?>
1.Function
2.File
3.Strings
4.Array
What will be the output of the following PHP program? <?php define("VAR_NAME","test"); ${VAR_NAME} = "value"; echo VAR_NAME; echo ${VAR_NAME}; ?>
1. testtest
2.testvalue
3.error, constant value cannot be changed
4. test
What will be the value of the variable $input in the following PHP program? <?php $input = "PHP<td>stands for</td>Hypertext<i>Preprocessor</i>!"; $input = strip_tags($input,"<i></i>"); echo $input; ?>
1.PHP stands for Hypertext <i>Preprocessor</i>!
2.PHP stands for Hypertext Preprocessor!
3.PHP <td>stands for</td> Hypertext <i>Preprocessor</i>!
4.PHP <td>stands for</td> Hypertext Preprocessor!
Which is the right way of declaring a variable in PHP?
1.$3hello
2. $_hello
3.$_hello
4.$this
Which of the following is the correct syntax to write a PHP code?
1.<?php ?>
2.< php >
3.< ? php ?>
4.<? ?>
Which of the following is the correct way to add a comment in PHP code?
1.#
2.//
3./* */
4.All of the mentioned
Which of the following PHP functions can be used for generating unique ids?
1.md5()
2.uniqueid()
3.mdid()
4.id()
Which of the following variables does PHP use to authenticate a user? i) $_SERVER['PHP_AUTH_USER']. ii) $_SERVER['PHP_AUTH_USERS']. iii) $_SERVER['PHP_AUTH_PU']. iv) $_SERVER['PHP_AUTH_PW'].
1. ii) and iv)
2. i) and iv)
3.ii) and iii)
4.i) and ii)
Which one of the following is the default PHP session name?
1.PHPSESSIONID
2.PHPIDSESS
3.PHPSESSID
4.PHPSESID
Which PHP statement will give output as $x on the screen?
1.echo “$x”;
2.echo “$$x”;
3.echo “/$x”;
4.echo “$x;”;
Which variable is used to collect form data sent with both the GET and POST methods?
1.$_BOTH
2.$REQUEST
3.$_REQUEST
4.$BOTH
Which version of PHP introduced the advanced concepts of OOP?
1.PHP 6
2.PHP 4
3.PHP 5
4.PHP 5.3
Who is the father of PHP?
1. Drek Kolkevi
2.Rasmus Lerdorf
3.Willam Makepiece
4.List Barely