PHP Interview Question and Answers

PHP Interview Question and Answers

Online Training in India

1) What’s PHP ?

A) The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.

2) Who is the father of PHP ?

A) Rasmus Lerdorf is known as the father of PHP.

3) What’s the difference between include and require?

A) It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

4) What is the difference between $name and $$name?

A) $name is variable where as $$name is reference variable like $name=sonia and $$name=singh so $sonia value is singh.

5) How can we submit a form without a submit button?

A) Java script submit() function is used for submit form without submit button on click call document.formname.submit()

6) What does a special set of tags <?= and ?> do in PHP?

A) The output is displayed directly to the browser.

7) How do you define a constant?

A) Via define() directive, like define (“MYCONSTANT”, 100);

8) What is the difference between mysql_fetch_object and mysql_fetch_array?

A) MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array

9) How do you pass a variable by value?

A) Just like in C++, put an ampersand in front of it, like $a = &$b

10) Are objects passed by value or by reference?

A) Everything is passed by value.

11) How can we create a database using PHP and MySQL?

A) We can create MySQL database with the use of mysql_create_db(“Database Name”)

12) How do you pass a variable by value?

A) Just like in C++, put an ampersand in front of it, like $a = &$b

13) What is the difference between the functions unlink and unset in PHP?

A) The function unlink() is to remove a file, where as unset() is used for destroying a variable that was declared earlier. unset() empties a variable or contents of file.

14) What is the default session time in PHP?

Until closing the browser.

15) How will you create a database using PHP and MySQL?

A) By using : mysql_create_db(“Database Name”)

16) How will you find out the value of current session id?

A) By using: session_id()

17) How can we destroy the cookie?

A) Set the cookie with a past expiration time.

18) How can we submit from without a submit button?

A) Trigger the JavaScript code on any event ( like onSelect of drop down list box, onfocus, etc ) document.myform.submit(); This will submit the form.

19) What is the maximum size of a file that can be uploaded using PHP and how can we change this?

A) You can change maximum size of a file set upload_max_filesize variable in php.ini file.

20) What type of inheritance that php supports?

A) In PHP an extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword ‘extends’.

For Best PHP Online Training please visit http://www.revanthtechnologies.com

Save