You are on page 1of 23

1) Simple protocol for data exchange between computers.

• URL
• IP
• Server
• DNS
2) PHP stands for.
• Hypertext Preprocessor
• Pretext Hypertext Preprocessor
• Personal Home Preprocessor
• None of the above
3) We will need a way to transfer our website files from the
local computer to the remote web server. We do this by using
• Web server
• Web site
• FTP
• Web browser
4) Variable name in PHP starts with
• !
• $
• &
• #
5) Which of the following is not a variable scope in PHP
• Extern
• Local
• Static
• Global
6) What will be the output of the following code

<?php
$cars = array ("Volvo", "BMW", "Toyota");
echo "My car is a {$cars [0]}";
?>

• My car is a Toyota
• My car is a BMW
• Error
• My Car is a Volvo
7) Which of the following is correct to add a comment in PHP
• &………&
• //……….
• /*……..*/
• Both (2) and (3)
8) Which of the following is known as the key to object-
oriented programming
• Polymorphism
• Data Abstraction
• Orthogonality
• Encapsulation
9) The Practice of separating the user from the true inner
workings of an application through well-known interfaces is
known as
• Abstraction
• Encapsulation
• Polymorphism
• Inheritance
10) which of the following is used to display output in PHP
• echo
• write
• print
• both (1) and (3)
11) Which of the following is the use of srtlen() function in PHP
• Returns the type of a string
• Returns the length of a string
• Returns the value of a string
• Returns both value and type of a string

12) A computer software system for organizing and facilitating
collaborative creation of documents and other content,
especially for loading a website is
• SMS
• CSM
• CMS
• GSM
13) A warning is displayed and the script continues to run
• None
• With include

• With require
14) What is the description of error level E_ERROR?
• Fatal Compile-time error
• Compile-time error
• Near-Fatal error
• Fatal run-time error
15) Which of the following is used for concatenation in PHP
• *
• .
• +
• Append
16) How do you create a cookie in PHP?
• makecookie ()
• setcookie ()
• createcookie ()
• None
17) Which of the following web-server is used for PHP scripts
• Cassini
• Tomcat
• IIS
• Apache
18) Which of the following starts with double underscore ( __ )
in PHP
• Magic constants
• Default constants
• User-defined constants
• Inbuilt constants
19) Work by creating a unique id (UID) for each visitor and
storing variables base on this UID
• Sessions

• None
• Cookies
20) …….. is software used by an end user to access the web
• Web Server
• Web site
• The Web
• A Web browser
21) ……… is a technology which facilitates a disciplined
approach to designing computer programs that enhance the
functionality and appearance of the Web pages.
• CSS
• HTML
• Java Script
• Bootstrap
22) an error is displayed and the script stops.
• None

• With require
• With include
23) How do you get information from a form that is submitted
using the "get" method?
• []Get_$
• Request.Query string
• Request.Form
• None
24) What will be the output of the following PHP code?
<?php
$a = 10; $b = 10;
if ($a = 5)
$b-- ;
print $a; print $b--;
?>

• 109
• 1010
• Error
• 59
25) Which of the following is the correct way to create a
function in PHP
• create myFunction ()
• New_function myFuntion ()
• function myfunction ()
• None of the above
26) What will be the output of the following PHP code?
<?php
$x = 10;
$y = 10;
If ($x > $y && 1 || 1)
Print "1000 PHP MCQ";
else
print "Welcome to Sanfoundary";
?>

• 1000 PHP MCQ


• error
• no output
• Welcome to Sanfoundry
27) ……… is the collection of machines (Web servers) on the
internet that provide information, particularly HTML
documents, via HTTP.
• Web Server
• The Web
• A web browser
• Web site
28) What is the use of fopen() in PHP?
• To open files in PHP
• To open Folders in PHP
• To open remote server in PHP
• None of the above
29) What is the use of isset() function in PHP?
• To check whether variable is set or not
• To check whether variable is free or not
• To check whether variable is string or not
• None of the above
30) nLaravel is ……… PHP framework create by taylor Otwell in
2011
• MVC
• MCV
• None
• VCM
31) Read only web is
• Web 3.0
• Web 1.0
• Web 4.0
• Web 2.0
32) Which of the following functions is used to sort an array in
descending order?
• Sort ()
• Asort ()
• Dsort ()
• Rsort ()
33) PHP supports AJAX?
• Yes
• No

• None
34) Which one of the following can be used to instantiate an
object in PHP assuming class name to be Foo?
• obj = new foo ();
• $obj = new foo ();
• $obj = new foo;
• $obj = new $foo;
35) What is the correct way to end a PHP statement?
• .
• none
• ;
• </php>
36) Used to create database transactions
• None
• Data Manipulation Language (DML)
• Data Definition Language (DDL)
• Control Language (CL)
37) ….. are transferred between server and client according to
http.
• Cookies
• None

• Sessions
38) The PHP syntax is most similar to:
• JavaScript
• VBScript
• Perl and C
• CSS
39) Identifier for the locations of a document on a web site
• HTML
• BNS
• IP
• URL
40) When using the POST method, variables are displayed in
the URL:
• False
• None

• True
41) Software that listens for web page requests
• Web server
• Web site
• The web
• A web browser
42) When you use the $_GET variable to collect data, the data is
visible to …………….
• None
• Everyone
• Selected few
• Only clients
43) In PHP you can use both single quotes (' ') and double
quotes (" ") for strings:
• False
• none
• True
44) Which one of the following function is used to start a
session?
• session_start ()
• session_begin ()
• start_session ()
• begin_session ()
45) Which of the following statements is/are true about
Constructor in PHP?
i) PHP 4 introduced class constructor.
ii) Constructor can accept parameters.
iii) Constructor can all class methods or other functions.
iv) Class constructor can call on other constructors.
• ii)
• ii) and iii)
• ii), iii) and iv)
• i), ii), iii) and iv)
46) We use DNS
• To open connection to server
• To response to browser over connection
• To request over connection
• To locate IP address
47) What is the correct way to include the file "time.inc"?
• <?php include:"time.inc"; ?>
• <!-- include file="time.inc"-->
• <?php include "time.inc"; ?>
• <?php include file="time.inc"; ?>
48) What will be the output of the following code?

<?php
define("VAR_NAME", "test");
${VAR_NAME} = "value";
echo VAR_NAME;
echo ${VAR_NAME};
?>

• test
• testtest
• testvalue
• error, constant value cannot be changed
49) Set of related web pages served from a single web domain,
hosted on one or more web servers
• the web
• web site
• web server
• A web browser
50) What is the correct way to open the file "time.txt" as
readable?
• open ("time.txt","read");
• fopen ("time.txt","r");
• fopen ("time.txt","r+");
• open ("time.txt");
51) Used to insert, update, delete, and view the data in
database objects
• none
• Control Language (CL)
• Data Definition Language (DDL)
• Data Manipulation Language (DML)
52) We use to end sessions:
• set($_SESSION[name])
• set($_SESSION['name'])
• unset($_SESSION['name'])
• unset($_SESSION[name])
53) If the directive session.cookie_lifetime is set to 3600, the
cookie will be live until
• 3600 hrs
• 3600 min
• 3600 sec
• The browser is restarted
54) PHP allows you to send emails directly from a script
• True

• False
• None
55) Which superglobal variable holds information about
headers, paths, and script locations?
• $_SERVER
• $_GLOBALS
• $_GET
• $_SESSION
56) Which of the following type of variables have only two
possible values either true or false?
• Doubles
• Integers
• Strings
• Booleans
57) The bootstrap grid system works across multiple devices in
order to
• Add interactivity to website
• Add responsiveness to website
• None
• Add supportiveness to website
58) If your object must inherit behavior from a number of
sources you must use a/an
• Object
• Interface
• Abstract class
• Static class
59) What is the correct way to add 1 to the $count variable?
• count++;
• ++count
• $count =+ 1
• $count++;
60) Which of the following keyword is used to inherit our
subclass into a superclass?
• include
• implements
• extends
• inherit
61) Which two predefined variables are used to retrieve
information from forms?
• $_GET & $_SET
• $__GET & $__SET
• $GET & $SET
• GET & SET
62) PHP can be run on Microsoft Windows IIS (Internet
Information Server):
• False

• None
• True
63) When you use the $_POST variable to collect data, the data
in visible to
• None
• Everyone
• Only you
• Selected few
64) The die() and exit() functions do the exact same thing
• False
• True

• None
65) Which one of these variables has an illegal name
• $myVar
• $my_Var
• $my-var
• All of them
66) 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;
?>
• 5
• Error
• 10
• 15
67) What will be the output of the following PHP code?

<?php
$username = "jasoN";
if (ereg ("([^a-z])" , $username))
echo "Username must be all lowercase!";
else
echo "Username is all lowercase!";
?>

• Username must be all lowercase!


• No Output is returned
• Error
• Username is all lowercase!
68) How do we create a cookie in PHP?
• makecookie()
• createcookie()
• setcookie()
• None
69) Set of commands understood by a web server and sent
from a browser:
• IP
• URL
• HTTP
• DNS
70) What will be the output of the following PHP code?
<?php
class MyClass
{
}
$a = new MyClass;
var_dump(!($a instanceof stdClass));
?>

• Error
• None of the above
• bool(true)
• bool(false)
71) Used to create and modify database objects
• Control Language (CL)
• Data Definition Language (DDL)
• None
• Data Manipulation Language (DML)
72) What will be the output of the following PHP code?
<?php
$x = 1;
$y = 2;
if (++$x == $y++)
{
echo "true ", $y, $x;
}
?>

• true 22
• No output
• true 33
• true 23
73) What will be the output of the following PHP code?
<?php
echo "This", "was", "a", "bad", "idea";
?>

• Thiswasabadidea
• error
• This was a bad idea
• This, was, a, bad, idea

You might also like