Category Archives: Php Interview Questions

Difference between mysql_connect and mysql_pconnect?

Difference between mysql_connect and mysql_pconnect?

mysql_pconnect : Creates a persistent connection to the database that means a SQL link do not close when the execution of your script ends. Mysql_pconnect checks if that if the same host, username and password connection is already opened an identifier for it will be returned instead of making a new connection. While mysql_connect() provides the connection and closes the connection when script execution ends.

How to define a constant in PHP ?

Use define() directive to define a constant in php.
example-
(“MY_CONSTANT”,10);

How we can retrieve the data in PHP from MySQL

How we can retrieve the data in PHP from MySQL

There are following method to retrive data from database in php

1. mysql_fetch_row –

2. mysql_fetch_array-

3. mysql_fetch_object-

4. mysql_fetch_assoc-

What is HTTP?

The Hypertext Transfer Protocol (HTTP) is used to enable communications between clients and servers.
HTTP works as a request-response protocol between a client and server.

Differences between GET and POST methods

Differences between GET and POST methods

GET : Data in get method is not secured. Data is displayed in the browser. There can be 1024 bytes send using this method. GET requests can be cached. GET requests remain in the browser history

POST : POST method is secure and not displayed in browser. There is no limit to post data using the POST method.
POST requests are not cached. POST requests does not remains in the browser history.

What is the difference between include and require?

What is the difference between include and require?

Require : Requires stops execution when file is not found and causes fatal error.

Include : Include continues the execution when file is not found and generates warning.

What is the difference between echo and print in php

What is the difference between echo and print in php

Both Echo and print are constructs.
echo is more efficient because it does not return any value.
Print returns a value most like a function but its construct .

One major difference is that echo can take multiple input parameters while print takes only one parameter.

echo ‘test5’, ‘test6’; // Concatenates the 2 strings
print(‘test5’, ‘test6’); // Fatal error

What is php ??

Php Stands as ‘PHP: Hypertext Preprocessor’ .PHP is a server side scripting language mostly used for web the web applications.PHP scripts is executed on the server. Php also supports object oriented programming.