PHP multiple choice Questions and Answers Skip to main content

Recent Posts

On A Winter's Night - Munshi Premchand

On  A Winter's Night - Munshi Premchand About the Author  Munshi Prem Chand (1880-1936) was the most renowned figure of Hindi literary world. He enriched Hindi-Urdu literature by writing numerous books in the genre of story and novel. He centred his writings to village and people of lower class. He used simple language which was used by the villagers in day-to-day conversation. He took birth at Lamhi village in Banaras. His stories are the mouthpiece of problems of peasant class.  About the Lesson  The lesson 'On a Winter's Night' is a story which takes us into the first quarter of twentieth century. How peasants used to suffer by the atrocity of landlords, is the subject-matter of this story. The story is the English version of Prem Chand's Hindi story 'Poos ki Raat'. Halku was a poor Indian farmer in pre-independence period. He worked hard but he and his family had to suffer a lot. These people had to remain poor throughout their life.  Halku and his ...

PHP multiple choice Questions and Answers

php multiple choice questions and answers 

PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used, free .The Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases

1. PHP Stands for

A. Php Hypertext Processor

B. Php Hypertext Preprocessor

C. Php Hypermarkup Preprocessor

D. Php Hypermarkup Processor

2. PHP is _______ scripting language.

A. Server-side

B. Clint-side 

C. Middle-side

D. Out-side


Android Java project s


3. PHP scripts are executed on _________

A. ISP Computer

B. Client Computer

C. Server Computer

D. It depends on PHP scripts

4. PHP Scripts starts with ________

A. <php> … </php>

B. <?php …. ?>

C. ?php … ?php

D. <p> … </p>

5. Which of the following statements prints in PHP?

A. Out

B. Write

C. Echo

D. Display

6. In PHP, each statement must be end with ______

A. . (dot)

B. ; (semicolon)

C. / (slash)

D. : (colon)

7. In PHP Language variables name starts with _____

A. ! (Exclamation)

B. & (Ampersand)

C. * (Asterisk)

D. $ (Dollar)

8. In PHP Language variables are case sensitive

A. True

B. False

C. Depends on website

D. Depends on server

9. In PHP a variable needs to be declare before assign

A. True

B. False

C. Depends on website

D. Depends on server

10. Which of the following is not the scope of Variable in PHP?

A. Local

B. Global

C. Static

D. Extern


11. What is the use of strlen( ) function in PHP?

A. It returns the type of a string

B. It returns the value of a string

C. It returns the length of a string

D. It returns the subset value of a string

12. Which of the following is the Concatenation Operator in PHP?

A. + (Plus)

B. . (dot) 

C. & (Ampersand)

D. % (Percentage)

13. Which of the following is not PHP Loops?

A. while

B. do while

C. for

D. do for

14. What is the use of strpos( ) function in PHP?

A. Search for a number within a string

B. Search for a Spaces within a string

C. Search for a character/text within a string

D. Search for a Capitalized string/text with in a string

15. Where setcookie( ) function must appear in PHP?

A. Before tag

B. After tag

C. In tag

D. Anywhere

16. What does the hash (#) sign mean in PHP?

A. It indicates lines that are commented out.

B. It indicates variable declaration.

C. It indicates function declaration.

D. No uses in PHP.

17. How to define a variable in PHP?

A. $variable_name = value

B. $variable_name = value;

C. $variable_name == value;

D. $variable_name as value;

18. The uses of strcmp( ) function in PHP?

A. It compare strings including case

B. It compare strings excluding case

C. It compare strings only Uppercase

D. It compare strings only lowercase

19. What will be the result of combining a string with another data type in PHP?

A. int

B. float

C. string

D. double

20. Data for a cookie stored in _________ in PHP?

A. In ISP Computer

B. In User’s Computer

C. In Server Computer

D. It depends on PHP Coding


21. PHP is a ______ typed language.

A. User

B. Loosely

C. Server

D. System

22. What does fopen() function do in PHP?

A. It used to open files in PHP

B. It used to open Remote Server 

C. It used to open folders in PHP

D. It used to open Remote Computer

23. Where session_start() function must appear in PHP?

A. Anywhere

B. With <html> tag

C. After <html>tag

D. Before <html> tag

24. What does the PHP Interpreter do?

A. It translates User Language to System Language

B. It creates connection between ISP & Server

C. It processes the HTML and PHP files

D. All of these

25. Which of the following is used to add comments in PHP?

A. //

B. /* … */

C. & … &

D. Only A & B

26. What does sprintf() function do in PHP?

A. it sends output to a variable

B. it prints the output of program

C. it sends output to a variable converting into string

D. it prints the output of program converting into string

27. Variables are case-sensitive in PHP?

A. True

B. False

28. Which function displays the information about PHP?

A. info()

B. sysinfo()

C. phpinfo()

D. php_info()

29. What does isset() function do in PHP?

A. There is no such function in PHP

B. It checks whether variable is set or not

C. It checks whether variable is free or not

D. It checks whether variable is string or integer

30. How PHP files can be accessed?

A. Through Web Browser

B. Through HTML files

C. Through Web Server

D. All of Above

31. A script is a

A. Program or sequence of instructions that is interpreted or carried out by processor directly

b. Program or sequence of instruction that is interpreted or carried out by another

program

c. Program or sequence of instruction that is interpreted or carried out by web

server only

d. None of above

32. When compared to the compiled program, scripts run

a. Faster

b. Slower

c. The execution speed is similar

d. All of above

33. PHP is a widely used ……………. scripting language that is especially suited for

web development and can be embedded into html

a. Open source general purpose

b. Proprietary general purpose

c. Open source special purpose

d. Proprietary special purpose

24. Which of the following is not true?

a. PHP can be used to develop web applications.

b. PHP makes a website dynamic.

c. PHP applications can not be compiled.

d. PHP can not be embedded into html.

25. The most portable version of PHP tag that is compatible to embed in XML or

XHTML too is:

a. <? ?>

b. <script language=”php”> </script>

c. <% %>

d. 

26. Which of the following variables is not a predefined variable?

a. $get

b. $ask

c. $request

d. $post

27. You can define a constant by using the define() function. Once a constant is

defined

a. It can never be changed or undefined

b. It can never be changed but can be undefined

c. It can be changed but can not be undefined

d. It can be changed and can be undefined

28. The following piece of script will output:

<?

$email=’admin@psexam.com’;

$new=strstr($email, ‘@&rsquo ;

print $new;

?>

a. admin

b. admin@psexam

c. @psexam.com

d. psexam.com

29. Which of the following function returns the number of characters in a string

variable?

a. count($variable)

b. len($variable)

c. strcount($variable)

d. strlen($variable)

40. When you need to obtain the ASCII value of a character which of the following

function you apply in PHP?

a. chr( );

b. asc( );

c. ord( );

d. val( );

41. A variable $word is set to “HELLO WORLD”, which of the following script returns in

title case?

a. echo ucwords($word)

b. echo ucwords(strtolower($word)

c. echo ucfirst($word)

d. echo ucfirst(strtolower($word)

42. The difference between include() and require()

a. are different how they handle failure

b. both are same in every aspects

c. is include() produced a Fatal Error while require results in a Warning

d. none of above

43. When a file is included the code it contains, behave for variable scope of the line

on which the include occurs

a. Any variable available at that line in the calling file will be available within the

called file from that point

b. Any variable available at that line in the calling file will not be available within the

called file

c. Variables are local in both called and calling files

d. None of above

44. Which of the following method sends input to a script via a URL?

a. Get

b. Post

c. Both

d. None

45. Which of the following method is suitable when you need to send larger form

submissions?

a. Get

b. Post

c. Both Get and Post

d. There is no direct way for larger form. You need to store them in a file and

retrieve

46. Which of the following mode of fopen() function opens a file only for writing. If a file

with that name does not exist, attempts to create anew file. If the file exist, place the file

pointer at the end of the file after all other data.

a. W

b. W+

c. A

d. A+

47. The function setcookie( ) is used to

a. Enable or disable cookie support

b. Declare cookie variables

c. Store data in cookie variable

d. All of above

48. To work with remote files in PHP you need to enable

a. allow_url_fopen

b. allow_remote_files

c. both of above

d. none of above

49. fopen($file_doc,”r+&rdquo opens a file for

a. reading

b. writing

c. none of above

d. both of above


50. In mail($param2, $param2, $param3, $param4), the $param2 contains:

a. The message

b. The recipient

c. The header

d. The subject

51. mysql_connect( ) does not take following parameter

a. database host

b. user ID

c. password

d. database name

52. Study following steps and determine the correct order

(1) Open a connection to MySql server

(2) Execute the SQL query

(3) Fetch the data from query

(4) Select database

(5) Close Connection

a. 1, 4, 2, 3, 5

b. 4, 1, 2, 3, 5

c. 1, 5, 4, 2, 1

d. 4, 1, 3, 2, 5

53. Which of the following is not a session function?

a. sssion_decode

b. session_destroy

c. session_id

d. session_pw

54. When uploading a file if the UPLOAD_ERR-OK contains value 0 it means

a. Uplaod is not successful, error occurred

b. The file uploaded with success

c. Uploaded file size is 0

d. File upload progress is 0% completed 

55. Which of the following delimiter syntax is PHP's default delimiter syntax

a. <? php ?>

b. <% %>

c. <? ?>

d. <script language="php"> </script>

56. Which of the following statement produce different output

a. <?echo "This is php example"; ?>

b. <P="This is php example"; ?>

c. <?PHP echo "This is php example"; php?>

d. <script language="php"> print "This is php example";</script>

57. Which of the following delimiter is ASP style?

a. 

b. <% %>

c. <? ?>

d. <script language="php"> </script>

58. Php supports all four different ways of delimiting. In this context identify the false

statement

a. You can use any of the delimiting style

b. You can use different delimiting styles in same page

c. You can use any delimiting style but must use a single style consistently for a

page

d. Variables declared in previous blocks are remenbered on later blocks too!

59. Which of following commenting is supported by Php

a. Single line c++ syntax - //

b. Shell syntax - #

c. Both of above

d. None of above

60. To produce the output6 I love the summer time, Which of the ofllowing statement

should be used?

a. <? Php print ("<P> I love the summer time</p>" ;?>

b. <? Php $ season="summer time"; print"<p> I love the $ season</p>"; ?>

c. <?Php $ message="<p> I love the summer time </p>; ecdho $ message; ?>

d. All of above

61. Which of following function return 1 when output is successful?

a. echo ( )

b. print ( )

c. both
d. None

62. Which of followng statement is more suitable if you want to output a blend of
static text and dynamic information stored within one or several variables?
a. echo ( )
b. print ( )
c. Print f ( )
d.  of above

63. Which of the following type specifier is invalid in print f ( ) functions
a. % a
b. % b
c. % c
d. % d

64. Which of the following function can assign the output to a string variable
a. echo ( )
b. print ( )
c. print f ( )
d. s print f ( )

65. Which of the following data type is not seal or datetype supported by PHP
a. Array
b. String
c. Float
d. Boolean

66. Which of the following data type is compound datatype supported by PHP
a. Array
b. String
c. Float
d. Boolean

67. If a boolean variable $ alive= 5;
a. $ alive is false
b. $ alive is true
c. $ alive is overflow
d. the statement is snot valid

68. For integer data type PHP 6 introduced
a. 8 bit integer value
b. 16 bit integer value
c. 32 bit integer value
d. 64 bit integer value

69. For integer data type PHP 5 and earlier supported
a. 8 bit integer value
b. 16 bit integer value
c. 32 bit integer value
d. 64 bit integer value


70. Trace the odd data type
a. floats
b. integer
c. doubles
d. Real number

71. Which of the folowing are valid float values?
a. 4.5678
b. 4.0
c. 7e4
d. All of above

72. In php string data are
a. delimited by single quote
b. delimited by double quote
c. delimited by <<< identifier
d. All of above

73. Which of the following delimiting method is known as string Interpolation
a. delimited by single quote
b. delimited by double quote
c. delimited by <<< identifier
d. All of above

74. Which datatypes are treaded as arrays
a. Integer
b. Float
c. String
d. Booleans

75. Which of following are compound data type?
a. Array
b. Objects
c. Both
d. None

76. Casting operator introduced in PHP 6 is
a. (array)
b. (int64)
c. (real) or (double) or (float)
d. (object)

77. When defining identifier in PHP you should remember that
a. Identifier are case sensitive. So $result is different than $ result
b. Identifiers can be any length
c. Both of above
d. None of above

78. Identify the invalid identifier
a. my-function
b. size
c. –some word
d. This&that

79. Which of folowiing variable assignment is 'by value' assignment in PHP
a. $value1= $value?
b. $value1= & $value?
c. $value1= & $value?
d. None

80. Identify the variable scope that is not supported by PHP


a. Local variables

b. Function parameters

c. Hidden variables

d. Global variables

81. The output of ofllowing script would be

$somerar=15;
function ad it () {
GLOBAL $somevar;
$somerar++ ;
echo "somerar is $somerar";
}
addit ();

a. somerar is 15

b. somerar is 16

c. somerar is 1

d. somerar is $ somerar

82. Variable scope on which a variable does not loose its value when the function

exists and use that value if the function is called again is:

a. Local

b. function parameter

c. static

d. None of above


83. The left association operator % is used in PHP for
a. percentage

b. bitwise or

c. division

d. modulus

84. The left associative dot operator (.) is used in PHP for

a. multiplication

b. concatenation

c. separate object and its member

d. delimeter

85. Trace the false statement

a. Any code found within an included file will inherit the variable scope of the location
of its calle

b. Because the included code will be embedded in a PHP execution block, the PHP execution block, the PHP escape tags (<?php?> aren't required on the file to be included

c. For the inclusion of remote files the allow-url-pope must be enabled ad URL wrapper must be supported

d. Including a file produces the same result as copying the data from the file specified

into the location in which the statement appears.

86. Which of the following functions require the allow-url-fopen must be enabled?

a. include()

b. require()

c. both of above

d. None of above

87. Which function includes the specified file even the statement evaluates to false in

which block the function is placed.

a. include ()

b. require ()

c. both of above

d. None of above

88. On failure of which statement the script execution stops displaying error/warning

message?

a. rinclude ()

b. require ()

c. both of above

d. None of above

89. Trace the function that does continue the script execution even if the file inclusion

fails

a. include ()

b. require ()

c. both of above

d. None of above

Comments