bidezones.com /PHP/PHP MCQ Sample Test,Sample questions

Question:
  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

Posted Date:-2022-02-16 06:17:47


Question:
 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}

Posted Date:-2022-02-16 06:00:56


Question:
 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

Posted Date:-2022-02-16 06:26:10


Question:
 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

Posted Date:-2022-02-16 06:03:14


Question:
 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

Posted Date:-2022-02-16 07:03:41


Question:
 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

Posted Date:-2022-02-16 06:09:13


Question:
 Which of the following is the default file extension of PHP files?

1..php

2..ph

3..xml

4..html

Posted Date:-2022-02-16 05:56:09


Question:
 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)

Posted Date:-2022-02-16 06:51:32


Question:
 Which PHP function displays the web page’s most recent modification date?

1.getlastmod()

2.get_last_mod()

3.lastmod()

4. last_mod()

Posted Date:-2022-02-16 07:01:33


Question:
 Which PHP function displays the web page’s most recent modification date?
a) 

1.getlastmod()

2.get_last_mod()

3.lastmod()

4. last_mod()

Posted Date:-2022-02-16 07:01:32


Question:
. 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

Posted Date:-2022-02-16 06:12:53


Question:
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

Posted Date:-2022-02-16 06:16:00


Question:
If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?

1.1

2.5

3.12

4.Error

Posted Date:-2022-02-16 07:08:06


Question:
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

Posted Date:-2022-02-16 06:38:37


Question:
What does PDO stand for?

1.PHP Database Orientation

2.PHP Data Orientation

3.PHP Data Object

4.PHP Database Objec

Posted Date:-2022-02-16 06:47:49


Question:
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

Posted Date:-2022-02-16 05:53:24


Question:
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

Posted Date:-2022-02-16 05:52:02


Question:
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

Posted Date:-2022-02-16 06:56:44


Question:
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

Posted Date:-2022-02-16 06:35:59


Question:
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

Posted Date:-2022-02-16 06:14:45


Question:
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

Posted Date:-2022-02-16 06:57:46


Question:
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

Posted Date:-2022-02-16 06:50:06


Question:
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

Posted Date:-2022-02-16 06:07:55


Question:
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

Posted Date:-2022-02-16 07:02:46


Question:
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

Posted Date:-2022-02-16 06:59:39


Question:
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

Posted Date:-2022-02-16 07:06:46


Question:
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

Posted Date:-2022-02-16 07:07:24


Question:
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

Posted Date:-2022-02-16 07:00:33


Question:
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!

Posted Date:-2022-02-16 06:45:34


Question:
Which is the right way of declaring a variable in PHP?

1.$3hello

2. $_hello

3.$_hello

4.$this

Posted Date:-2022-02-16 06:06:33


Question:
Which of the following is the correct syntax to write a PHP code?

1.<?php ?>

2.< php >

3.< ? php ?>

4.<? ?>

Posted Date:-2022-02-16 05:54:27


Question:
Which of the following is the correct way to add a comment in PHP code?

1.#

2.//

3./* */

4.All of the mentioned

Posted Date:-2022-02-16 05:55:00


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

1.md5()

2.uniqueid()

3.mdid()

4.id()

Posted Date:-2022-02-16 06:09:56


Question:
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)

Posted Date:-2022-02-16 06:46:57


Question:
Which one of the following is the default PHP session name?

1.PHPSESSIONID

2.PHPIDSESS

3.PHPSESSID

4.PHPSESID

Posted Date:-2022-02-16 06:58:34


Question:
Which PHP statement will give output as $x on the screen?

1.echo “$x”;

2.echo “$$x”;

3.echo “/$x”;

4.echo “$x;”;

Posted Date:-2022-02-16 06:55:18


Question:
Which variable is used to collect form data sent with both the GET and POST methods?

1.$_BOTH

2.$REQUEST

3.$_REQUEST

4.$BOTH

Posted Date:-2022-02-16 07:04:33


Question:
Which version of PHP introduced the advanced concepts of OOP?

1.PHP 6

2.PHP 4

3.PHP 5

4.PHP 5.3

Posted Date:-2022-02-16 06:56:05


Question:
Who is the father of PHP?

1. Drek Kolkevi

2.Rasmus Lerdorf

3.Willam Makepiece

4.List Barely

Posted Date:-2022-02-16 05:52:36


More MCQS[bidezones.com ]

  1. PHP Mcq Set 1
  2. PHP Mcq Set 2
  3. PHP Mcq Set 3
  4. PHP Mcq Set 4
  5. Current affairs mcq php
  6. Current affairs mcq php set 2
  7. Current affairs mcq php set 3
  8. PHP MCQ
  9. PHP MCQ Basics
  10. PHP Mcq Functions
  11. PHP Mcq Arrays
  12. PHP Mcq Basics of Object-Oriented PHP
  13. PHP Mcq Error Handling
  14. PHP Basics Mcq Questions