Suscriber with us



Receive HTML?

Syndicate

php interview question part1 PDF Print E-mail

1.What will be the following script output?

<?php
$x = 3 - 5 % 3;
echo $x;
?>
A. 2
B. 1
C. no
D. right
E. 3

Answer B is correct.

2.Which data type will the $a variable have at the end of the following script?

<?php
$a = “1”;
echo $x;
?>

A. (int) 1
B. (string) “1”
C. (wood) True
D. (float) 1.0
E. (float) 1

Answer B is correct.

3.What will be the following script output?

<?php
$a = 1;
$a = $a— + 1;
echo $a;
?>

A. 2
B. 1
C. 3
D. 0
E. Null

Answer B is correct.

4.Is it possible to pass data form PHP to JavaScript?

A. right, because PHP is server-side, and JavaScript is client-side.
B. rong, because PHP is a loosely typed language.
C. no, because JavaScript executes before PHP.
D. Yes, because PHP can generate valid JavaScript.

Answer D is correct.

JavaScript, like DHTML, can be dynamically generated by
PHP. Answers A and B are incorrect because the answer is yes. Answer C is incorrect because PHP executes before JavaScript.

5.Which type of from elements can be excluded from the HTTP request?

A. text, radio butten, and check box
B. text, submit, and hidden
C. submit and hidden
D. radio and check box

Answer D is correct.

6.Which of the following from element names can be used to create an array in PHP?

1. foot
B. [foot]
C. foot []
D. foot [bar]

Answer C is correct.

PHP will create an enumerated array called foot that contains
the values of all form elements named foot [] in the HTML form.Answers A, B,
and D are incorrect because any subsequent form elements of the same name will
overwrite the value in previous elements.

7.Why must you call session _start() orior to any output?

A. Because it is easy to forget if not placed at the top of your scripts.
B. Because you can no longer access the session data store after there has been
output.
C. Because session_start() sets some HTTP headers.
D. Because calling session_start() causes the HTTP headers to be sent.

Answer C is correct.

Answer A is incorrect because this is a technical necessity, not
a best practice. Answer B is incorrect because accessing the session data store is
completely independent of whether there has been any output. Answer D is incorrect
because you can set other HTTP headers after a call to session_start().

8.Which of the following function allows you to store session data in adatabase?

A. session_start();
B. session_set_save_handler();
C. mysql_query();
D. You cannot store session data in a database.

Answer B is correct.

You can use session_set_save_handler() to override
PHP’s default session-handling functions and store session data any way you want.
Answer A is incorrect because session_start() only activates PHP sessions for
the current script. Answer C is incorrect because mysql_query() only executes a
query with MySQL and does not affect the behavior of PHP’s session mechanism.
Answer D is incorrect because this statement is false.

9.Which of the following type can be used as an array key? (Select three.)

A. empty
B. Floating-point
C. Array
D. function
E. Boolean

Answers A, B, and E are correct.

A Boolean value will be converted to either 0 if
it is false or 1 if it is true, whereas a floating-point value will be truncated to its integer equivalent.

10.When an expiration date is given in a set-Cookie header, what is the resulting behavior in subsequent requests?

A. If the expiration date has expired, the cookie is not included.
B. The behavior is the same; the expiration date is included in the Cookie
header, and you can access this information in the $_COOKIE superglobal
array.
C. The cookie persists in memory until the browser is closed.
D. The cookie is deleted and therefore not included in subsequent requests.

Answer A is correct.

Answer B is incorrect because only the name and value of the
cookie are included in the Cookie header. Answer C is incorrect because setting
an expiration date causes a cookie to either be deleted (if the date has expired) or written to disk. Answer D is incorrect because the cookie is only deleted if the date has expired, which isn’t necessarily the case.




Digg!Del.icio.us!Google!Live!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Yahoo!Free social bookmarking plugins and extensions for Joomla! websites!
Last Updated ( Thursday, 13 March 2008 )
 
< Prev

Download Utility

XAMPP
WAMP
EditPlus
Zend Studio

Polls

Which is the best Scripting language?