PHP Interview Questions

Page

1.Who is the father of PHP ?

Ans: Rasmus Lerdorf  is known as the father of PHP.

2.what is difference between echo and print?

Ans: print returns the value in true or false, where as echo does not return anything.

3.What are the differences between Get and post methods?

Ans: There are two differences,

GET Method have some limit like only 2Kb data able to send for request. But in POST method unlimited data can we send. when we use GET method requested data show in url, but not in POST method .So POST method  is good for send sensetive request.

4.what is difference between explode and implode?

 Ans: Explode function:-it breaks a string into array.

Implode:-returns a string from elements of an array.

 5. How can we create a database using PHP and MySQL?

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

 6.what is terinary operation in php?

 Ans: Expression preceding the ? is evaluated, if it’s true, then the expression preceding  the : is executed, otherwise, the expression following : is executed.
<?php
$variable = (Condition) ? ‘expression1’ : ‘expression2’;
?>

7.What are the differences between require and include?

Ans: Both include and require used to include a file, but when included file not found Include send Warning . Where as Require send a Fatal Error .

 8.What is use of header() function in php ?

 Ans: The header() function sends a raw HTTP header to a client. We can use header() function for redirection of pages.

 9.what is difference between require() and require_once()?

 Ans: require() includes and evaluates a specific file while require_once() does that only if it has not been included before (on the same page).

10.what is difference between include() and include_once()?

 Ans: include() includes and evaluates a specific file while include_once() does that only if it has not been included before (on the same page).

11.What is Isset()?

Ans: isset() determines whether a certain variable has already been declared by PHP. It returns a boolean value true if the variable has already been set, and false otherwise, or if the variable is set to the value NULL.

12.what is difference between drop table and truncate table?

 Ans: DROP TABLE  table_name – This will delete the table and its data.

TRUNCATE TABLE  table_name – This will delete the data of the table, but not the table definition.

13.What are the new features added in PHP5 ?

 Ans: Addition features of PHP5 are,

1.Visibility
2.Abstract
3.Final
4.Methods
5.Class
6.Magic methods or functions
7.Interface
8.Cloning
9.Typehinting

14.What is htaccess?

Ans: .htaccess files are configuration files of Apache Server which provide
a way to make configuration changes on a per-directory basis

15. What is the difference between the functions unlink and unset?

Ans: unlink() deletes the given file from the file system.
unset() makes a variable undefined.

16.How many ways we can pass the variable through the navigation between the pages?

Ans:

  • GET
  • POST

17.What is the difference between char and varchar data types?

Ans: Set char to occupy n bytes and it will take n bytes even if you are
storing a value of n-m bytes.
Set varchar to occupy n bytes and it will take only the required space
and will not use the n bytes.
eg. name char(15) will waste 10 bytes if we store ‘josephmons’, if each char
takes a byte
eg. name varchar(15) will just use 5 bytes if we store ‘josephmons’, if each
char takes a byte. rest 10 bytes will be free.

18.What is the functionality of md5 function in PHP?

Ans: Calculate the md5 hash of a string. The hash is a 32-character
hexadecimal number. I use it to generate keys which I use to identify
users etc. If I add random no techniques to it the md5 generated now
will be totally different for the same string I am using.

19.what is PDO ?

Ans: The PDO ( PHP Data Objects ) extension defines a lightweight, consistent interface for accessing databases in PHP.

20.What is a Session?

Ans:It can be used to store information on the server for future use.

21.What are ways to include a file to a php page?

Ans: We can include a file using ‘include() ‘, ‘include_once()‘, ‘require()‘ or ‘require_once()‘ function with as its parameter.

22.What are the advantages/disadvantages of MySQL and PHP?

Ans: These two are open source software (so free of cost), support
cross platform. php is faster then ASP and JSP.

 

 

Leave a comment