PHP Programming MCQ Questions and Answers | SPPU

PHP PROGRAMMING MCQ QUESTIONS AND ANSWERS


1. PHP stands for_________

A.  htpertext processor

B.  pretext hyper processor

C.  preprocessor home page

D.  none of above

Answer : A.  htpertext processor

 

2. What is the syntax of PHP code ?

A.  <PHP>

B.  <?PHP?>

C.  <?PHP??

D.  //PHP//

Answer : B.  <?PHP?>

 

3. What is the concatenation operator in PHP?

A.  =

B.  +

C.  ,

D.  .

Answer : D.  .

 

4. What is the correct way of declaring PHP variables?

A.  $name

B.  $7hello

C.  $this

D.  name

Answer : A.  $name

 

5. PHP is the correct way of declaring PHP variables?

A. 1

B.  -1

C.  0

D.  +1

Answer : C.  0

 

 6. What is the correct way for creating array in PHP?

i.  weekday[0]=”Monday”;

ii.  $weekday[]=array(“Monday”,”Tuesday”,”Wednesday”);

iii.  $weekday[0]=”Monday”;

iv.  $weekday=array(“Monday”);

A. i and ii 

B.  ii and iii

C.  iii and iv

D.  i and iv

Answer : C.  iii and iv

 

7. PHP is __________ scripting language.

A.  client side

B.  server side

C.  browser side

D.  none of these

Answer : B.  server side

 

8. Which function is used to sort array in ascending order?

A.  sort()

B.  rsort()

C.  dsort()

D.  none of above

Answer : A.  sort()

 

9. There are three different kind of arrays:

A.  Numeric array, String Array, Multidimensional array

B.  Numeric array, Associative array, Dimensional array

C.  Numeric array, associative array, Multidimensional array

D. Const array, Associative array, Multidimensional array

Answer : C.  Numeric array, associative array, Multidimensional array

 

10. Assume you would like to sort an array in ascending order by value while preserving key associations. Which of the following PHP sorting functions would you use?

A.  Ksort()

B.  assort()

C.  krsort()

D.  sort()

Answer :  B.  assort()

 

11. Two main structures of branching are____________

A.  if and switch

B.  if and do while

C.  if and for

D.  none of the above

Answer : A.  if and switch

 

12. Which of the conditional statements is/are supported by PHP?

A.  if statements

B.  if-else statements

C.  All of the above

D.  switch statements

Answer : C.  All of the above

 

13. Correct syntax of foreach loop is _______

A. foreach($arrayy as $var){

                //code to be executed

} 

B.  foreach($array as $key=>$var){

//code to be executed

}

C.  foreach($var as $array){
                //code to be executed

}

D.  Both i) and ii)

Answer : D.  Both i) and ii)

 

14. do-while loop is called as________

A.  Entry controlled loop

B.  exit controlled loop

C.  entry exit controlled loop

D.  None of the above

Answer : B.  exit controlled loop

 

15. In a switch-case statement, default can be written__________

A.  any where

B.  should be the last statement

C.  First statement

D.  None of the above

Answer : B.  should be the last statement

 

16. Basic syntax for calling a function is

A. function_name(expression1,expersion2)

B. (expression 1: Function_name, expersion 2 : Function_name)

C. (expression 1, expersion 2)

D. None of them

Answer : A.  function_name(expression1,expersion2)

 

17. Which function will return true if a variable is an array or false otherwise?

A.  this_array()

B.  is_array()

C.  unset()

D.  in_array()

Answer : B.  is_array()

 

18. Which of the following PHP function is used to build a function that accepts any number of arguments?

A.  func_get_argv()

B.  func_get_args()

C.  get_argv()

D.  get_argc()

Answer : B.  func_get_args()

 

19. Which build-in function will add a value to the end of the array

A.  array_shift()

B.  array_unshift()

C.  array_push()

D.  into_array()

Answer : C.  array_push()

 

20. which notation is used to access variables of an object?

A.  ::

B.  =

C.  ->

D. .

Answer : C.  ->

 

21. Which notation should be used to refer to a method in the context of a class rather than an object you use?

A.  ->

B.  _

C.  $

D.  ::

Answer : D.  ::

 

22.  Which method is invoked just before an object is garbage collected?

A.  _collect()

B.  _garbage()

C.  _destruct()

D.  _destructor()

Answer : C.  _destruct()

 

23. which one of the following property scopes is not supported by PHP?

A.  friendly()

B.  final

C.  public

D.  static

Answer : A.  friendly()

 

24. which function is used to check if class is exists or not?

A.  exist()

B.  exist_class()

C.  class_exist()

D.  _exits()

Answer : C.  class_exist()

 

25. Which keyword is used to refer to properties or methods within the class itself?

A.  private

B.  public

C.  protected

D.  $this

Answer : D.  $this

 

26.  When you use the $_GET variable to collect data, the data is visible to ___________

A.  none

B.   only you

C.  everyone

D.  selected few

Answer : C.  everyone

 

27. When you use the $_POST variable to collect data, the data is visible to ____________

A. none

B.  only you

C.  everyone

D.  selected few

Answer : B.  only you

 

28. Which one of the following should not be used while sending passwords or other sensitive information?

A. GET 

B.  POST

C.  REQUEST

D.  NEXT

Answer : A. GET 

 

29. Which method has larger limit on the amount of data that can be passed to web server?

A.  GET

B.  POST

C.  PUT

D.  SET

Answer : B.  POST

 

 30. If we use_______ as value for target attribute in form tag, then the response will display in current page only.

A.  _self

B.  _blank

C.  _post

D.  _get

Answer : A.  _self

 

31. Which one of following should not be used while sending sensitive information?

A.  GET

B.  POST

C.  REQUEST

D. NEXT

Answer : A.  GET

 

32. To validate email address, which flag is passes to filter_val() function?

A.  FILTER_VALIDATE_EMAIL

B. FILET_VALIDATE_EMAIL

C.  VALIDATE_EMAIL

D.  VALIDATE_EMAIL

Answer : A.  FILTER_VALIDATE_EMAIL

 

33. How many function PHP offers for searching and modifying string using PCRE?

A. 7 

B.  8

C.  9

D.  10

Answer : B.  8

 

34. PHP supports for two regular expression implementations known as _____ and_____.

i.  perl

ii.  PEAR

iii.  POSIX

iv.  regex1

Answer :

A.  i and iii

B.  ii and iii

C.  I and iv

D.  ii and iii

Answer : B.  ii and iii

 

35. which of the following is correct about preg_match() function?

A.  The preg_match() function is used to search specified string by string, returns true if the pattern found otherwise false.

B.  The preg_match() function searches throughout string specified by pattern for a string specified by string. The search is not case sensitive.

C.  The preg_match() function searches sting for pattern, returning true if pattern exist otherwise false.

D.  None of above

Answer : A.  The preg_match() function is used to search specified string by string, returns true if the pattern found otherwise false.

 

36. PHP sessions are created using the _______ function.

A.  session_starts()

B.  sessions_start()

C.  session_start()

D.  none of above

Answer : C.  session_start()

 

37. When you want to store user data in a session use the ________array.

A. $_SESSION

B.  $YS_SESSION

C.  $SESSION

D.  $_SESSIONS

Answer : A. $_SESSION

 

38. Session allow you to

A.  store persistent user preference on a site

B.  save user authentication information from page to page

C.  create multipage forms

D.  all of above

Answer : D.  all of above

 

39. session_destroy() instantly destroy elements of the $_SESSION array.

A.  true

B.  false

Answer : B.  false

 

40. In PHP cookies are set by using

A.  setcookie() function

B.  set() function

C.  COOKIE_SET() function

D.  None of Above

Answer : A.  setcookie() function

 

41. The attack which involves the insertion of malicious code into a page frequented byy other users is knows as.

A.  basic SQL injection

B.  Advanced SQL Injection

C.  Cross-site Scripting

D.  Scripting

Answer : C.  Cross-site Scripting

 

42. To remove all global session variables, use

A. session_unset() 

B.  Unset()

C.  Unsetsession

D.  $unset()

Answer : A. session_unset() 

 

43. To destroy the session, we use

A. $destroy() 

B. session_destroy()

C.  destroy_session

D.  session_destroy()

Answer : D.  session_destroy()

 

44. Which of the following database is supported by php from beginning

A.  SQL

B.  ORACLE

C.  PostgreSQL

D.  MySQL

Answer : D.  MySQL

 

45. Which of the following statement is used to create a table.

A. create table table_name(columnname columntype); 

B.  create table_name(column_name column_type);

C.  create table_name(column_name, column_type);

D.   create table table_name(column_type, column_name);

Answer : A. create table table_name(columnname columntype); 

 

46. which of the following statement initialized mysqli class?

A.  $mysqli=new mysqli();

B.  $mysqli->new.mysqli();

C.  mysqli->new.mysqli();

D.  None of Above

Answer : A.  $mysqli=new mysqli();

 

47. which method returns the error code generated from the execution of the last mysql function?

A.  errno();

B.  errnumber();

C.  erorno();

D.  errornumber();

Answer : A.  errno();

 

48. Which of the following function is used to select the database?

A.  $mysqli=select_db(‘databasename’);

B.  mysqli=select_db(‘databasename’);

C.  mysqli->select_db(‘databasename’);

D.  $mysqli->select_db(‘databasename’);

Answer : D.  $mysqli->select_db(‘databasename’);

 

49. which of the following method is used to retrieve the number of rows affected by insert, update or delete query?

A.  num_rows();

B.  affected_rows();

C.  changed_rows();

D.  select_rows();

Answer : A.  num_rows();

 

50. Which of the following method is responsible for sending the query to database

A.  query();

B.  send_query();

C.  sendQuery();

D.  None of Above

Answer : A.  query();

PHP Programming MCQ Questions and Answers | SPPU PHP Programming MCQ Questions and Answers | SPPU Reviewed by technical_saurabh on March 17, 2021 Rating: 5

No comments:

Powered by Blogger.