Monday 19 March 2012

MCQ For PHP


  1. What PHP stand for?
A) Hypertext Preposessor
B)     Pre Hypertext Preposessor
C)     Pre Hyper Preposessor
D)     Pre Hypertext Process

  1. Which of the following tags is a valid way to begin and end a php block code.
A)     <% %>
B)     <? ?>
C)     <! !>
D)     <?php ?>

  1. How does the identify operator === compare two values?
A)     it converts them to a common compatible data type and then compares the resulting values.
B)     It returns true only if they are both of the same type and value
C)     If the two values are string, it performs a lexical comparison
D)     It bases its comparisons on the C strcmp function exclusively

  1. variables always start with a ___________ in php
A)     pond-sign
B)     yen-sign
C)     Doller-sign
D)     Euro - sign

5.  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

6. 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

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

8. Which of the following variables is not a predefined variable?
A) $get
B) $ask
C) $request
D) $post

9. 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

10. 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)

11. 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( );

12. 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

13. Which of the following method sends input to a script via a URL?
A) Get
B) Post
C) Both
D) None

14. 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

15. 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+

16. 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

17. PHP is an open source software
A) True
B) False

18. Array values are keyed by _____ values(called indexed array) or using ____ value (called associative array). Of course, these key methods can be combined as well.
A) Float, string
B) positive number, negative number
C) String, Boolean
D) Integer, string

19. What will the following script output
<?php
     $array = array(1,2,3,5,8,13,21,34,55)
     $num=0;
     For($i=0;$i<5;$i++)
     {
              $num += $array[$array[$i]];
     }
     echo $num;
?>
A) 78
B) 19
C) Null
D) 5

20. What elements will the following script output?
<?php
     $array = array(true =>’a’, 1=>’b’)
     Var_dump($array);
?>
A) 1=>’b’
B) true=>’a’,1=>’b’
C) 0=>’a’,1=>’b’
D) it will output null

21. which array function checks if the specified key exist in the array.
A) array_key_exist()
B) array_key_exists()
C) array_keys_exist()
D) arrays_key_exists()

22. There are three different kind of array.
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

23. Assume you would like to sort an array in ascending order by value while preserving key association. Which of the following PHP sorting functions would you use?
A) ksort()
B) assort()
C) krsort()
D) sort

24. What function count elements in an array?
A) count
     B) Sizeof
     C) Array_count
     D) count_array

25. Which of the following will combine string $s1 and $s2 into a single string?
A) $s1.$s2
B) $s1+$s2
C) $s1,$s2
     D) All of Above

26. Given a variable $email containing the string user@example.com, which of the following statement would extract the string example.com?
A) substr($email, strops($email, “@”));
B) strstr($email,”@”)
C) strchr($email,”@”)
     D) substr($email,strops($email,”@”)+1)

27. what is the best all purpose way of comparing two string?
A) using the strpos()
B) using the == operator
C) using strcasecmp()
     D) using strcmp()

28. which of the following PCRE regular expression best matches the string php|architect?
A) .*
B)…|…….
C) \d{3}\/\d{8}
     D) [a-z][a-z][a-z]\|\w{9}

29. The ______ function can be used to compare two string using a case-insensitive binary algorithm
A) strcmp()
B) stricmp()
C) strcasecmp()
     D) stristr()

30. ^[0-9]{5}(\-[0-9]{4})?$ mathces
A) 90001 and 90002-4323
B) 9001 and 12-4321

31. which of the following function retrieve the entire content of a file in a such a way that it can be used as part of an expression?
A) file_get_contents()
B) fgets()
C) fopen()
D) file()

32. fgets() is used to read a file one line at a time.
A) true
B) false

32. The ______ function checks if the “end-of-file” (EOF) has been reached.
A) f_eof()
B) f_of()
C) feofs()
D) feof()

34. The _____ function is used to read a single character from file.
A) fgetc()
B) fgets()
C) fget()
D) fgetf()

35. Which of the following function do not return timestamp?
A) time()
B) date()
C) strtotime()
D) localtime()

36. The getdate() function returns
A) An integer
B) A floating-point number
C) An array
D) A boolean                         

37. _____ checks a date for numeric validity.
A) check_date
B) verifydate
C) verify_date
D) checkdate

38. In PHP in order to access MySql database you will use:
A) mysqlconnect() function
B) mysql-connect() function
C) mysql_connect() function
D) sql_connect() function

39. transaction are used to treat sets of SQL statement automatically.
A) true
B) false

40. How do you write "Hello World" in PHP
A) Document.Write("Hello World");
B) echo "Hello World";
C) "Hello World";   
D) None of this

41. What is the correct way to end a PHP statement?
A) ;
B) .
C) New line
D) </php>

42. How do you get information from a form that is submitted using the "get" method?
A) $_GET[];
B) Request.Form;
C) Request.QueryString;
D) All of above

43. When using the POST method, variables are displayed in the URL:
A) False
B) True

44. In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:
A) True
B) False

45. Include files must have the file extension ".inc"
A) True
B) False

46. What is the correct way to include the file "time.inc" ?
A) <!--include file="time.inc"-->
B) <% include file="time.inc" %>
C) <?php require("time.inc"); ?>
D) <?php include_file("time.inc"); ?>

47. What is the correct way to create a function in PHP?
A) create myFunction()
B) new_function myFunction()
C) function myFunction()
D) None of this

48. What is the correct way to open the file "time.txt" as readable?
A) open("time.txt");
B) open("time.txt","read");
C) fopen("time.txt","r+");
D) fopen("time.txt","r");

49. What is the correct way to connect to a MySQL database?
A) connect_mysql("localhost");
B) dbopen("localhost");
C) mysql_open("localhost");
D) mysql_connect("localhost");

50. What is the correct way to add 1 to the $count variable?
A) $count++;
B) count++;
C) ++count
D) $count =+1

51. PHP can be run on Microsoft Windows IIS(Internet Information Server):
A) True
B) False

52. In PHP, the die() and exit() functions do the exact same thing.
A) True
B) False

Answer

1)     A                 
2)     D                
3)     A                
4)     C                
5)     B                 
6)     A                
7)     D                
8)     B                 
9)     A                
10)  D               
11)  C               
12)  A               
13)  A               
14)  B                
15)  C               
16)  C               
17)  A               
18)  D               
19)  A               
20)  D               
21)  B                
22)  C               
23)  B
24)  A
25)  A
26)  D
27)  D
28)  D
29)  C
30)  A
31)  A
32)  A
33)  D
34)  A
35)  D
36)  C
37)  A
38)  C
39)  A
40)  B
41)  A
42)  A
43)  B
44)  A
45)  B
46)  C
47)  C
48)  D
49)  D
50)  A
51)  A
52)  A

Posted By : Hemangi Zala

1 comment: