Php Objective Type Questions

39
1. What is the default execution time set in set_time_limit()? You answered: 20 secs Incorrect Correct answer: 30 secs 2. What is the difference between GET and POST method? Correct 3. How do we submit form data without a Sumbit button? You answered: Using Javascript Incorrect Correct answer: Both a and b above i.e., using javascript and using header() 4. What happens if no file path is given in include() function? You answered: PHP continues to execute the script. Incorrect Correct answer: Include_path is made use of 5. What does explode() do? You answered: Used to convert a string to an array. Incorrect Correct answer: Used to split a string by a string 6. How do I find out the number of parameters passed into function? Correct By using func_num_args() 7. How can we count the number of elements in an array? Correct using sizeof() and count() 8. Can we use include (”test.php”) two times in a PHP page “test1.PHP”? Correct - YES 9. In which variable is the users IP address stored? Correct $REMOTE_ADDR 10. What is the default size of a file set in upload_max_filesize ? You answered: 2.5 MB Incorrect Correct answer: 2 MB

Transcript of Php Objective Type Questions

Page 1: Php Objective Type Questions

1. What is the default execution time set in set_time_limit()?You answered: 20 secsIncorrect Correct answer: 30 secs 2. What is the difference between GET and POST method?Correct 3. How do we submit form data without a Sumbit button?You answered: Using JavascriptIncorrect Correct answer: Both a and b above i.e., using javascript and using header() 4. What happens if no file path is given in include() function?You answered: PHP continues to execute the script.Incorrect Correct answer: Include_path is made use of 5. What does explode() do?You answered: Used to convert a string to an array.Incorrect Correct answer: Used to split a string by a string 6. How do I find out the number of parameters passed into function?

Correct By using func_num_args() 7. How can we count the number of elements in an array?Correctusing sizeof() and count() 8. Can we use include (”test.php”) two times in a PHP page “test1.PHP”?Correct - YES 9. In which variable is the users IP address stored?

Correct $REMOTE_ADDR 10. What is the default size of a file set in upload_max_filesize ?You answered: 2.5 MBIncorrect Correct answer: 2 MB

Page 2: Php Objective Type Questions

11. Which of the following way below is correct to comment a single line of code in php?You answered: //Commented lineIncorrect Correct answer: both and b above // and # 12. How do we start a php session?Correct session_start(); 13. Can echo in php accept more than 1 parameter?Correct 14. What is the purpose of $_SESSION[]?Correct - Can store session variables 15. Can I have new lines in $subject tag of php's mail function?You answered: Yes by specifying /nIncorrect Correct answer: No 16. In mysql_fetch_array() If two or more columns of the result have the same field names, what action is taken?Correct

the last column will take precedence 17. What is the use of mysql_pconnect()?You answered: Used to create a persistant connection to mysql server.Incorrect Correct answer: Both b and c above

Used to create a persistant connection to mysql server.

Used to return an identifier of an existing open connection before opening new connection. 18. What is Joomla in PHP?Correct Open source CMS 19. What is the difference between echo and print?Correct 20. ____________ function in PHP Returns a list of response headers sent (or ready to send)You answered: header()

Page 3: Php Objective Type Questions

Incorrect Correct answer: headers_list() 21. PHP supports both simple and multi-dimensional arraysCorrect - YEs 22. What is array_keys() used for?Correct 23. The windows version of PHP does not have built-in support for the calendar extensionCorrect - False 24. Which of the following statements is FALSE for PHP Error and Logging?You answered: Both a and c belowIncorrect Correct answer: trigger_error() and user_error() are different 25. Parent constructors are not called __________ if the child class defines a constructorCorrect - implicitly 26. What is PHP heredoc used for?You answered: allows creating multiple lines of string with quotationsIncorrect Correct answer: allows creating multiple lines of string without using quotations 27. A PHP function cannot be overloaded or redefinedYou answered: FalseIncorrect Correct answer: True 28. PHP supports explicit type definition in variable declaration.Correct 29. How do I create PHP arrays in a HTML <form>?Correct

< input name="MyArray[]" /> 30. Can I generate DLL files from PHP scripts like i can in Perl ?You answered: YesIncorrect Correct answer: No 31. How can I run COM object from remote server ?

Page 4: Php Objective Type Questions

You answered: pass the IP of the remote machine as first parameter to the COM constructor.Incorrect Correct answer: Both a and c above

like we run local objects

pass the IP of the remote machine as second parameter to the COM constructor. 32. Can I run several versions of PHP at the same time?You answered: NoIncorrect Correct answer: Yes

Built-in native support for SQLite

improved MySQL support 33. Which of the following differences are valid between PHP 4 and PHP 5?Correct 34. Which of the following rules below is/are false for exceptions?You answered: Both a and b aboveIncorrect Correct answer: Exceptions cannot be thrown (or re-thrown) in a catch block within a try block 35. What is x+ mode in fopen() used for?

Correct - Read/Write. Creates a new file. Returns FALSE and an error if file already exists 36. What is the strpos() function used for?

Correct - Search for character within a string 37. Is strstr and strchr aliases?You answered: NoIncorrect Correct answer: Yes 38. Which function is used to Strip whitespace (or other characters) from the beginning and end of a string?Correct

Page 5: Php Objective Type Questions

39. echo does not return any valueCorrect

MYSQL1. What is a candidate key?Correct

Used to uniquely identify a row 2. Can I call a trigger directly called from an application?You answered: YesIncorrect Correct answer: No 3. A view is nothing but a ________ table or a stored queryCorrect - Virtual 4. How can we get the number of records or rows in a table?Correct

Using COUNT 5. An outer join requires each record in the two joined tables to have a matching record.Correct - NO 6. How do I find out all databases starting with ‘test to which I have access to?You answered: SHOW DATABASES LIKE ‘'test'%’;Incorrect Correct answer: SHOW DATABASES LIKE ‘test%’; 7. Can I define multiple unique constraints on a table?Correct

Yes 8. When do we use a HAVING clause?You answered: both b and c aboveIncorrect Correct answer: To limit the output of a query using an aggregate function only 9. USE keyword is used to select a ___________

Page 6: Php Objective Type Questions

Correct

Database 10. Enum values are stored accodring to their index numbersCorrect 11. Which of the following ways below are the correct way to get the current date?Correct

SELECT CURTIME();

SELECT CURDATE();

SELECT CURRENT_TIME(); 12. Which of the following file extension is a valid MyISAM file extension?You answered: .ismIncorrect Correct answer: .myd 13. User() fucntion returns the current users user name and ___________You answered: both a and b aboveIncorrect Correct answer: host name 14. –i-am-a-dummy flag is used Makes the MySQL engine refuse UPDATE and which other command?Correct

DELETE 15. Which is the default order of sort in ORDER BY clause?You answered: DescendingIncorrect Correct answer: Ascending 16. Can DISTINCT command be used for more than one column?Correct - YES 17. On executing DELETE command, if you get an error "foreign key constraint"- what does it imply?Correct

Page 7: Php Objective Type Questions

Data is present in the other table 18. BLOB data type can have default column value.Correct 19. How much storage space does DATETIME require?You answered: 2 bytesIncorrect Correct answer: 8 bytes 20. If an ENUM column is declared NOT NULL, its default value is the first element of the list of allowed values.You answered: False, ENUM column cannot be nullIncorrect Correct answer: True 1. What language defines the behavior of a web page?Correct 2. Which of the following is the tainted property of a window object in Java Script?You answered: ProtocolIncorrect Correct answer: Defaultstatus 3. How to append a value to an array of Java Script?You answered: arr[arr.length-1] = valueIncorrect Correct answer: arr[arr.length] = value 4. Why so Java and Java Script have similar name?You answered: None of the aboveIncorrect Correct answer: The syntax of Java is loosely based on Java syntax 5. Which machine actually executes the Java Script?You answered: Java Script engineIncorrect Correct answer: The machine which is running a web browser 6. Is it possible to declare a variable in Java Script along its type?You answered: NoIncorrect

Page 8: Php Objective Type Questions

Correct answer: Yes 7. Which of the following are capable of Java Script functions?You answered: all of the aboveIncorrect Correct answer: Accepting parameters 8. How does Java Script store dates in objects of Date type?You answered: The number of seconds since January 1st, 1970Incorrect Correct answer: The number of milliseconds since January 1st, 1970 9. Which attribute is used to hold the Java Script version?You answered: VERSIONIncorrect Correct answer: LANGUAGE 10. Which of the following is correct to write “Hello World” on the web page?Correct 11. Which of the following syntax is correct to refer an external script called “formValidation.js”?Correct 12. What type of image maps could be used with Java Script?Correct

Client-side image maps 13. Which of the following is the correct way for writing Java Script array?Correct 14. What is the purpose of <noscript> tag in Java Script?Correct 15. Java Script entities start with ____________ and end with ______________Correct - &,; 16. Which of the following is a server-side Java Script object?You answered: FileUploadIncorrect Correct answer: File 17. Which of the following is a client-side Java Script object?You answered: Time

Page 9: Php Objective Type Questions

Incorrect Correct answer: FileUpload - client side, File- server side 18. Which of the following method is used to evaluate a string of Java Script code in the context of the specified object?Correcteval()19. What is the event that fires when the form elements : <button>.<textarea> loses the focus?Correctonblur()20. Which of the following is used to capture all click events in a window?You answered: window.handleEvents (Event.CLICK);Incorrect Correct answer: window.captureEvents(Event.CLICK); 21. Javascript is an object oriented language?Correct - True 22. C-style block-level scoping is not supported in Java scriptYou answered: FalseIncorrect Correct answer: True 23. To insert a JavaScript into an HTML page, which tag is used?Correct - <script> 24. If we don’t want the script to write page content, under which HTML tag should the JS tag be placeD?You answered: Any of a and b aboveIncorrect Correct answer: < body> 25. Which of the following statements are true for Java script?Correct 26. Which of the following statements are false for Java script?You answered: Both b and c aboveIncorrect Correct answer: Variable names are not case sensitive 27. Which of the below is used in Java script to insert special characters?Correct - \ 28. JavaScript ignores extra spacesCorrect - YES

Page 10: Php Objective Type Questions

29. Which of the ways below is incorrect of instantiating a date?You answered: new Date(dateString)Incorrect Correct answer: new Date(seconds) 30. Which of the following statements are false for Java script?You answered: JavaScript can read and write HTML elementsIncorrect Correct answer: JavaScript cannot be used to create cookies 31. What is negative infinity in Java script?Correct-ve/0 32. ___________ JavaScript is also called client-side JavaScript.You answered: NativeIncorrect Correct answer: Navigator 33. Java script can be used for Storing the form's contents to a database file on the serverYou answered: TrueIncorrect Correct answer: False 34. Which of the following is not a valid JavaScript variable name?Correct 35. Which is the correct way to write a JavaScript array?Correct 36. File is server-side JavaScript objectYou answered: TrueIncorrect Correct answer: False 37. What java wrapper type is created when a JavaScript object is sent to Java?Correct

JSObject 38. Which attribute needs to be changed to make elements invisible?You answered: invisibleIncorrect

Page 11: Php Objective Type Questions

Correct answer: visibilty 39. Java Script supports all boolean operatorsYou answered: TrueIncorrect Correct answer: False 40. What is the alternate name for Java script?Correct

1) In PHP, arrays may be sorted with which of the following functions?

a) uksort()

b) arsort()

c) ksort()

d) (your answer) All of the above - correct answer

2) PHP comments for a single line have the following syntax:

a) /* comments /*

b) #

c) //

d) ::

e) (your answer) A&B - correct answer

3) Which of the following functions are used by PHP to find out what type a variable is?

a) gettype()

b) is_double()

c) (your answer) get_type()

d) is_date()

e) A&B - correct answer

Page 12: Php Objective Type Questions

4) The three possible connection states in PHP are ________.

a) normal

b) aborted

c) timeout

d) (your answer) All of the above - correct answer

5) In PHP, the error control operator is ________.

a) (your answer) *

b) %

c) @ - correct answer

d) &

6) In PHP, instructions are terminated with a _______.

a) (your answer) ; - correct answer

b) #

c) !

d) %>

7) What does PHP stand for?

a) (your answer) PHP: Hypertext Preprocessor - correct answer

b) Personal Home Page

c) Private Home Page

d) Personal Hypertext Processor

8) PHP server scripts are surrounded by delimiters, which?

Page 13: Php Objective Type Questions

a) <?php>...</?>

b) (your answer) <?php…?> - correct answer

c) <script>...</script>

d) <&>...</&>

9) How do you write "Hello World" in PHP

a) "Hello World";

b) (your answer) echo "Hello World"; - correct answer

c) Document.Write("Hello World");

d) response.write("Hello World")

10) All variables in PHP start with which symbol?

a) !

b) (your answer) $ - correct answer

c) &

d) #

11) Include files must have the file extension ".inc"

a) True

b) (your answer) False - correct answer

12) In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:

a) (your answer) True - correct answer

b) False

13) What is the correct way to include the file "time.inc" ?

Page 14: Php Objective Type Questions

a) <!--include file="time.inc"-->

b) <?php include_file("time.inc"); ?>

c) (your answer) <?php require("time.inc"); ?> - correct answer

d) <% include file="time.inc" %>

14) What is the correct way to create a function in PHP?

a) (your answer) function myFunction() - correct answer

b) new_function myFunction()

c) create myFunction()

15) What is the correct way to connect to a MySQL database?

a) mysql_open("localhost");

b) connect_mysql("localhost");

c) dbopen("localhost");

d) (your answer) mysql_connect("localhost"); - correct answer

16) What is the correct way to add 1 to the $count variable?

a) count++;

b) (your answer) $count++; - correct answer

c) ++count

d) $count =+1

17) PHP can be run on Microsoft Windows IIS(Internet Information Server):

a) (your answer) True - correct answer

b) False

Page 15: Php Objective Type Questions

18) In PHP 5, MySQL support is enabled by default:

a) (your answer) True

b) False - correct answer

19) Which one of these variables has an illegal name?

a) (your answer) $my-Var - correct answer

b) $myVar

c) $my_Var

20) Which of the following regular expressions will match the string no.no.no?

a) no?no?no

b) no*no*no*

c) ..\...\... - correct answer

d) (your answer) \.\..\.\..\.\.

21) A constructor is a special kind of…

a) Class

b) (your answer) Method - correct answer

c) Object

d) Variable

22) What can you use to replace like with hate in I like Eminem?

a) preg_replace("like", "hate", "I like Eminem") - correct answer

b) (your answer) preg_replace("/like/", "hate", "I like Eminem")

c) preg_replace("/like/", "/hate/", "I like Eminem")

d) preg_replace("hate", "like", "I like Eminem")

Page 16: Php Objective Type Questions

23) What library do you need in order to process images?

a) c-client library

b) GIF/PNG library

c) Image Library

d) (your answer) GD library - correct answer

24) What is the problem with <?=$expression ?> ?

a) It requires short tags and this is not compatible with XML - correct answer

b) There is no problem

c) (your answer) This syntax doesn't even exist It requires a special PHP library that may not always be available

25) What does break; do?

a) Ends execution of the current switch structure

b) Moves on to the next iteration of the current for, foreach, while, do-while or switch structure

c) (your answer) Ends execution of the current for, foreach, while, do-while or switch structure - correct answer

26) Can this PHP code be valid: $4bears = $bears->getFirst4();

a) Yes - correct answer

b) (your answer) No

27) Assuming all the variables a, b, c have already been defined, could this be a variable name: ${$a}[$b][$c] ?

a) Yes - correct answer

b) (your answer) No

Page 17: Php Objective Type Questions

28) Put this line php display_errors=false in a .htaccess file when you deploy the application?

a) That won't hide any error 'coz you can't use .htaccess to control the PHP engine Bad idea, I want to see when errors occur

b) (your answer) That won't hide any error 'coz it's not the correct code - correct answer

c) Good idea, increases security

29) What does this function do: <?php function my_func($variable) {return (is_numeric($variable) && $variable % 2 == 0);}?>

a) (your answer) tests whether $variable is a number and ends in 2

b) tests whether $variable ends in 2

c) tests whether $variable is a number and contains 2

d) tests whether $variable is an even number - correct answer

1) Inside which HTML element do we put the JavaScript?

a) <scripting>

b) <javascript>

c) (your answer) <script> - correct answer

d) <js>

2) What is the correct JavaScript syntax to write "Hello World"?

a) response.write("Hello World")

b) (your answer) document.write("Hello World") - correct answer

c) ("Hello World")

d) echo("Hello World")

Page 18: Php Objective Type Questions

3) How do you call a function named "myFunction"?

a) (your answer) call function myFunction

b) myFunction() - correct answer

c) call myFunction()

4) How do you write a conditional statement for executing some statements only if "i" is equal to 5?

a) if i==5 then

b) if i=5 then

c) (your answer) if (i==5) - correct answer

d) if i=5

5) How do you write a conditional statement for executing some statements only if "i" is NOT equal to 5?

a) (your answer) if (i <> 5)

b) if (i != 5) - correct answer

c) if =! 5 then

d) if <> 5

6) How many different kind of loops are there in JavaScript?

a) Two. The "for" loop and the "while" loop - correct answer

b) (your answer) Four. The "for" loop, the "while" loop, the "do...while" loop, and the "loop...until" loop

c) One. The "for" loop

7) How does a "for" loop start?

a) for (i = 0; i <= 5)

Page 19: Php Objective Type Questions

b) (your answer) for (i = 0; i <= 5; i++) - correct answer

c) for i = 1 to 5

d) for (i <= 5; i++)

8) What is the correct way to write a JavaScript array?

a) var txt = new Array(1:"tim",2:"shaq",3:"kobe")

b) var txt = new Array="tim","shaq","kobe"

c) (your answer) var txt = new Array("tim","shaq","kobe") - correct answer

9) How do you round the number 8.25, to the nearest whole number?

a) Math.rnd(8.25)

b) (your answer) Math.round(8.25) - correct answer

c) round(8.25)

d) rnd(8.25)

10) How do you find the largest number of 6 and 8?

a) (your answer) Math.max(6,8) - correct answer

b) top(6,8)

c) ceil(6,8)

d) Math.ceil(6,8)

11) What is the correct JavaScript syntax for opening a new window called "window5" ?

a) new("http://www.ex-designz.net","window5")

b) (your answer) window.open("http://www.ex-designz.net","window5") - correct answer

c) open.newwindow("http://www.ex-designz.net","window5")

d) new.window("http://www.ex-designz.net","window5")

Page 20: Php Objective Type Questions

12) How do you put a message in the browser's status bar?

a) window.status = "put your message here" - correct answer

b) statusbar = "put your message here"

c) status("put your message here")

d) (your answer) window.status("put your message here")

13) How do you find the client's browser name?

a) browser.name

b) (your answer) navigator.appName - correct answer

c) client.navName

14) You define an array using

a) (your answer) var myarray = new Array(); - correct answer

b) var myarray = array new;

c) var new Array() = myarray;

d) var new array = myarray;

15) Onclick is equivalent to which two events in sequence

a) onmouseover and onmousedown

b) onmousedown and onmouseout

c) (your answer) onmousedown and onmouseup - correct answer

d) onmouseup and onmouseout

16) Whicj best describe void?

a) (your answer) A method

Page 21: Php Objective Type Questions

b) A function

c) An operator - correct answer

d) A statement

17) Which property would you use to redirect visitor to another page?

a) (your answer) window.location.href - correct answer

b) document.href

c) java.redirect.url

d) link.redirect.href

18) Which of the following JavaScript statements use arrays?

a) (your answer) setTimeout("a["+i+"]",1000) - correct answer

b) k = a & i

c) k = a(i)

1)<?php$x=array("aaa","ttt","www","ttt","yyy","tttt");$y=array_count_values($x);echo $y[ttt];?>

a)2

b)3

c)1

d)4

Show Answer

2) How do you get information from a form that is submitted using the "get" method?

Page 22: Php Objective Type Questions

a)$_GET[];

b)Request.Form;

c)Request.QueryString;

d)$_POST[];

Show Answer

3)What's the best way to copy a file from within a piece of PHP?

a) Print out a message asking your user to "telnet" in to the server and copy the file for you

b) Open the input and output files, and use read() and write() to copy the data block by block until read() returns a zero

c) Use the built in copy() function

d) Use "exec" to run an operating system command such as cp (Unix, Linux) or copy (Windows)

Show Answer

4) PHP code is embedded directly into XHTML document?

a) False

b) True

Show Answer

5) Is it possible to submit a form with out a submit button?

a) Yes

b) No

Show Answer

6) Full form of PHP

Page 23: Php Objective Type Questions

a) PreHypertextProcessor

b) HypertextPreprocessor

c) Hypertext Postprocessor

d) PostHypertextProcessor

Show Answer

7) What is the expansion of LAMP?

a) Linux And Mysql Php

b) Linux Apache Mysql Php

Show Answer

8) In php Which method is used to getting browser properties?

a) $_SERVER['HTTP_USER_AGENT'];

b) $_SERVER['PHP_SELF']

c) $_SERVER['SERVER_NAME']

d) $_SERVER['HTTP_VARIENT']

Show Answer

9) Which of the following function is used to pick one or more random values from PHP Array?

a) array_rand()

b) array_random()

c) Random_array()

d) Rand_array()

Show Answer

Page 24: Php Objective Type Questions

10) <?php$x=array(1,3,2,3,7,8,9,7,3);$y=array_count_values($x);echo $y[8];?>

a) 43

b) 1

c) 8

d) 6

Show Answer

11) Assume that your php file 'index.php' in location c:/apache/htdocs/phptutor/index.php. If you used $_SERVER['PHP_SELF'] function in your page, then what is the return value of this function ?

a) phptutor/index.php

b) /phptutor/index.php

c) c:/apache/htdocs/phptutor/index.php

d) index.php

Show Answer

12) Which operator is used to concatenate two strings in php?

a) dot operator (.)

b) plus operator (+)

Show Answer

13)Are there regular expressions in PHP?

Page 25: Php Objective Type Questions

a) Yes - regular expressions use Perl-like conventions

b) Yes - PHP supports two different types of regular expressions: POSIX-extended and Perl-Compatible Regular Expressions (PCRE).

c) Yes - regular expressions use the POSIX standard

d) No - PHP uses "glob" style matching only

Show Answer

14) In PHP, which of the following function is used to insert content of one php file into another php file before server executes it

a) include[]

b) #include()

c) include()

d) #include{}

Show Answer

15) what will be the ouput of below code ? Assume that today is 2009-5-19:2:45:32 pm<?php$today = date("F j, Y, g:i a");

?>

a) may 19,09,2:45:32 PM

b) May 19, 2009, 2:45 pm

c) May 19,2009,14:45:32 pm

d) May 19,2009,14:45:32 PM

Show Answer

16) Which of the following function is used for terminate the script execution in PHP?

a) break()

Page 27: Php Objective Type Questions

a) 42

b) 56

c) Null

d) x=42

Show Answer

20) PHP variables are

a) Multitype variables

b) Double type variables

c) Single type variable

d) Trible type variables

Show Answer

21) Which of these statements is true?

a) PHP interfaces to the MySQL database,and you should transfer any data in Oracle or Sybase to MySQL if you want to use PHP on the data.

b) PHP interfaces to a number of relational databases such as MySQL, Oracle and Sybase. A wrapper layer is provided so that code written for one database can easily be transferred to another if you later switch your database engine.

c) PHP interfaces to a number of relational databases such as MySQL, Oracle and Sybase but the interface differs in each case.

d) There's little code in PHP to help you interface to databases, but there's no reason why you can't write such code if you want to.

Show Answer

22) Is php can support multiple inheritance?

a) NO

Page 29: Php Objective Type Questions

26) Assume that your php file 'index.php' in location c:/apache/htdocs/phptutor/index.php. If you used basename($_SERVER['PHP_SELF']) function in your page, then what is the return value of this function ?

a) phptutor

b) phptutor/index.php

c) index.php

d) /index.php

Show Answer

27) $x="display";${$x.'_result'} ();?>Above program will call the function display_result()

a) False

b) True

c) Parser Error

d) None of the above

Show Answer

28) All variables in PHP start with which symbol?

a) !

b) $

c) &

d) %

Show Answer

Page 31: Php Objective Type Questions

function zz(& $x){$x=$x+5;}?>$x=10;zz($x);echo $x;

a) 5

b) 0

c) 15

d) 10

Show Answer

33) <?phpecho $_SERVER['REMOTE_ADDR'];?>

a) shows the IP address of the local system

b) shows the IP address of the visitor

c) shows the IP address of the webserver

d) None of the above

Show Answer

34) <?php$x=dir(".");while($y=$x->read()){echo $y.""}$y->close();?>

Page 32: Php Objective Type Questions

What is the following output?

a) display all folder names

b) display a folder content

c) display content of the all drives

d) Parse error

Show Answer

35) <?php$qpt = 'QualityPointTechnologies';

echo preg_match("/^Quality/", $qpt);

?>

a) 1

b) 0

c) Quality

d) Null

Show Answer

36) <?php$test="3.5seconds";settype($test,"double");settype($test,"integer");settype($test,"string");print($test);?> What is the following output?

a) 3.5

b) 3.5seconds

c) 3

d) 3seconds

Page 35: Php Objective Type Questions

$qpt = 'Eat to live, but not live to eat';

echo preg_match("/^to/", $qpt);

?>

a) 0

b) 1

c) to

d) Null

Show Answer

44) <?php$x=array("aaa","","ccc","ddd","");$y=array_unique($x);echo count($x) . "," . count($y);?>

a) 3,1

b) 3,3

c) 5,5

d) 5,4

Show Answer

45) PHP is a _____ . It means you do not have to tell PHP which data type the variable is.PHP automatically converts the variable to the correct data type, depending on its value.

a) client side language

b) local language

c) global language

d) loosely typed language

Show Answer

Page 38: Php Objective Type Questions

a) 42

b) array(3) { [12]=> int(2) [13]=> int(56) ["x"]=> int(42) }

c) array(4) { [5]=>int(1) [12]=> int(2) [13]=> int(56) ["x"]=> int(42) }

d) 1,2,56,42

Show Answer

53) what will the ouptut of below date() function ?<?php$date="2009-5-19";$time="14:31:38";$datetime=$date.$time;echo date("Y-m-d:H:i:s",strtotime($datetime));?>

a) 2009-5-19:14:31:38

b) 2009-5-19:2:31:38

c) 19-5-2009:2:31:38

d) 19/5/2009:14:31:38

Show Answer

54) <?php$color=array("red","yellow","white");$x=in_array("black",$color);if($x==0)echo "good bye";if($x==1) echo "Hello";?>

a)Hello

b) Error

c) good bye

d) None of the above

Page 39: Php Objective Type Questions

Show Answer

Easy Learning - PHP

Answers

(1) a (2) a (3) c (4) b (5) a (6) b (7) b (8) a (9) a (10) b

(11) b (12) a (13) b (14) c (15) b (16) c (17) a (18) d (19) c (20) a

(21) c (22) a (23) b (24) a (25) a (26) c (27) b (28) b (29) b (30) c

(31) d (32) c (33) b (34) b (35) a (36) c (37) c (38) c (39) b (40) d

(41) a (42) b (43) a (44) d (45) d (46) a (47) a (48) b (49) a (50) b

(51) a (52) c (53) a (54) c