ii) //
PHP – Objective Questions – Unit IV & V iii) #
1. PHP - Hypertext Preprocessor iv) /* */
2. PHP files have a default file extension 8. Which of the following PHP
of_______ statement/statements will store 111 in variable
a) .html num?
b) .xml i) int $num = 111;
c) .php ii) int mum = 111;
d) .ph iii) $num = 111;
3. What should be the correct syntax to write iv) 111 = $num;
a PHP code? 9. Which of the following PHP
a) < php > statement/statements will store 111 in variable
b) < ? php ?> num?
c) <? ?> i) int $num = 111;
d) <?php ?> ii) int mum = 111;
4. Which of the following is/are a PHP code iii) $num = 111;
editor? iv) 111 = $num;
i) Notepad 10. Which of the following PHP statements
ii) Notepad++ will output Hello World on the screen?
iii) Adobe Dreamweaver i) echo (“Hello World”);
iv) PDT ii) print (“Hello World”);
5. Which of the following must be installed iii) printf (“Hello World”);
on your computer so as to run PHP script? iv) sprintf (“Hello World”);
i) Adobe Dreamweaver 11. Which of the below statements is
ii) XAMPP equivalent to $add += $add ?
iii) Apache and PHP a) $add = $add
iv) IIS b) $add = $add +$add
6. Which version of PHP introduced c) $add = $add + 1
Try/catch Exception? d) $add = $add + $add + 1
a) PHP 4 12. Which of the below symbols is a newline
b) PHP 5 character?
c) PHP 6 a) \r
d) PHP 5 and later b) \n
7. How should we add a single line comment c) /n
in our PHP code? d) /r
i) /?
13. Which of the conditional statements is/are c) memory_get_usage()
supported by PHP? d) memory_get_peak_usage()
i) if statements 19. Which of the following PHP functions can
ii) if-else statements be used for generating unique ids?
iii) if-elseif statements a) uniqueid()
iv) switch statements b) id()
14. How to define a function in PHP? c) md5()
a) function {function body} d) mdid()
b) data type functionName(parameters) {function 20. PHP’s numerically indexed array begin
body} with position ___________
c) functionName(parameters) {function body} a) 1
d) function functionName(parameters) {function b) 2
body} c) 0
15. A function in PHP which starts with __ d) -1
(double underscore) is know as.. 21. Which of the following are correct ways of
a) Magic Function creating an array?
b) Inbuilt Function i) state[0] = “karnataka”;
c) Default Function ii) $state[] = array(“karnataka”);
d) User Defined Function iii) $state[0] = “karnataka”;
16. Which of the following PHP functions iv) $state = array(“karnataka”);
accepts any number of parameters? 22. Which of the following function is used to
a) func_get_argv() get the value of the previous element in an array?
b) func_get_args() a) last()
c) get_argv() b) before()
d) get_argc() c) prev()
17. Which one of the following PHP functions d) previous()
can be used to find files? 23. What will be the output of the following PHP
a) glob() code ?
b) file()
1. <?php
c) fold() 2. $i = 0;
d) get_file() 3. while ($i = 10)
4. {
18. Which of the following PHP functions can
5. print "hi";
be used to get the current memory usage? 6. }
a) get_usage() 7. print "hello";
b) get_peak_usage() 8. ?>
a) hello c) I love my Country
b) infinite loop d) I Love My Country
c) hihello 27.The practice of creating objects based on
d) error predefined classes is often referred to as
24.What will be the output of the following PHP ______________
code ? a) class creation
1. <?php b) object creation
2. echo 5 * 9 / 3 + 9; c) object instantiation
3. ?> d) class instantiation
a) 24
28. Which one of the following property scopes is
b) 3.7
not supported by PHP?
c) 3.85
a) friendly
d) 0
b) final
25.What will be the output of the following PHP c) public
code? d) static
1. <?php 29. Which one of the following can be used to
2. function b()
instantiate an object in PHP assuming
3. {
4. echo "b is executed"; class name to be Foo?
5. } a) $obj = new $foo;
6. function a() b) $obj = new foo;
7. {
c) $obj = new foo ();
8. b();
9. echo "a is executed"; d) obj = new foo ();
10. b(); 30.Which of the following method scopes is/are
11. }
not supported by PHP?
12. a();
13. ?> i) private
a) b is executedb is executedb is executed ii) friendly
b) b is executeda is executed iii) static
c) a is executed iv) abstract
d) b is executeda is executedb is executed a) Only ii)
26.What will be the output of the following PHP b) Only iv)
code? c) ii) and iv)
d) Only i)
1. <?php
2. echo ucwords("i love my country"); 31.Which method scope prevents a method from
3. ?> being overridden by a subclass?
a) I love my country a) Abstract
b) i love my Country b) Protected
c) Final b) 3600
d) Static c) 1440
32.Which one of the following functions is used to d) 1540
determine object type? 38.Which one of the following function is used to
a) obj_type() start a session?
b) type() a) start_session()
c) is_a() b) session_start()
d) is_obj() c) session_begin()
33.Which keyword allows class members d) begin_session()
(methods and properties) to be used without 39.What is the default port number of HTTPs?
needing to instantiate a new instance of the class? a) 70
a) protected b) 80
b) final c) 90
c) static d) 100
d) private 40.Which one of the following function returns the
34.Which directive determines how the session port number of a specified service?
information will be stored? a) getportname()
a) save_data b) getservername()
b) session.save c) getserverbyname()
c) session.save_data d) getservbyname()
d) session.save_handler 41.Which one of the following function is used to
35.Which one of the following is the default PHP send an email using PHP script?
session name? a) mail_send()
a) PHPSESSID b) send_mail()
b) PHPSESID c) mailrr()
c) PHPSESSIONID d) mail()
d) PHPIDSESS 42.Which directive sets a maximum allowable
36.If session.use_cookie is set to 0, this results in amount of memory in megabytes that a script can
use of _____________ allow?
a) Session a) max_size
b) Cookie b) post_max_size
c) URL rewriting c) max_memory_limit
d) Nothing happens d) memory_limit
37.What is the default time(in seconds) for which 43.Which function is used to determine whether a
session data is considered valid? file was uploaded?
a) 1800 a) is_file_uploaded()
b) is_uploaded_file() d) CREATE TABLE table_name (column_type
c) file_uploaded(“filename”) column_name);
d) uploaded_file(“filename”) 49.Which method returns the error code
44.Which of the following variables does PHP use generated from the execution of the last MySQL
to authenticate a user? function?
i) $_SERVER[‘PHP_AUTH_USER’]. a) errno()
ii) $_SERVER[‘PHP_AUTH_USERS’]. b) errnumber()
iii) $_SERVER[‘PHP_AUTH_PU’]. c) errorno()
iv) $_SERVER[‘PHP_AUTH_PW’]. d) errornumber()
45.Which function is used to verify whether a 50. If there is no error, then what will the error()
variable contains a value? method return?
a) header() a) TRUE
b) footer() b) FALSE
c) inset() c) Empty String
d) isset() d) 0
46.The authenticationFile.txt, the file which stores
username and password should be stored ___ the 51. Which one of the following statements should
server document root. be used to include a file?
a) Inside a) #include ‘filename’;
b) Outside b) include ‘filename’;
c) Within c) @include ‘filename’;
d) None of the mentioned d) #include ;
47.Which one of the following databases has PHP 52. Which one of the following method is used to
supported almost since the beginning? retrieve the number of rows affected by an
a) Oracle Database INSERT, UPDATE, or DELETE query?
b) SQL a) num_rows()
c) SQL+ b) affected_rows()
d) MySQL c) changed_rows()
48.Which one of the following statements is used d) mysqli_affected_rows()
to create a table? 53. Which one of the following variable cannot be
a) CREATE TABLE table_name (column_name used inside a static method?
column_type); a) $this
b) CREATE table_name (column_type b) $get
column_name); c) $set
c) CREATE table_name (column_name d) $date
column_type);
54. What does PDO stand for?
a) PHP Data Orientation
b) PHP Database Object
c) PHP Database Orientation
d) PHP Data Object
55. Which one of the following is a constant
variable?
a) const $name
b) const $NAME
c) constant NAME
d) const NAME