What is PHP ?

PHP is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

As of January 2013, PHP was installed on more than 240 million websites (39% of those sampled) and 2.1 million web servers. Originally created by Rasmus Lerdorf in 1995, the reference implementation of PHP is now produced by The PHP Group. While PHP originally stood for Personal Home Page, it now stands for PHP: Hypertext Preprocessor, a recursive backronym.

PHP code is interpreted by a web server with a PHP processor module, which generates the resulting web page: PHP commands can be embedded directly into an HTML source document rather than calling an external file to process data. It has also evolved to include a command-line interface capability and can be used in standalone graphical applications.

PHP is free software released under the PHP License. PHP can be deployed on most web servers and also as a standalone shell on almost every operating system and platform, free of charge.

What is the difference between PHP session and cookie?

The main difference between sessions and cookies, ie, cookies are stored in the user’s browser, and sessions are not.

A “cookie” is a file that is physically stored on browser(your computer) and retained when you leave a web site and go somewhere else.

If a user has a login name and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit.


A session is a series of related HTTP requests and responses that together constitute a single conversation between a client and server.

Session variables hold information about one single user, and are available to all pages in one application.It will retain until user do not close the browser window.

Sessions work by creating a unique identification(SID) number for each visitor and storing variables based on this ID. It helps to prevent two users’ data from getting confused with one another when visiting the same web page.

How can we create a file using php script ?

In PHP, fopen() function is used to open files. (If does not exist,it will create a new file. It also helps to open file for writing(w) and appending(a).)

Create a File using fopen()
$fileName = “testFile.txt”;
$fileHandle = fopen($fileName , ‘w’) or die(“can’t open file”);
fclose($fileHandle );

What is the use of htaccess?

In several web servers (most commonly Apache), .htaccess (hypertext access) is the default name of a directory-level configuration file that allows for decentralized management of web server configuration. The .htaccess file is placed inside the web tree, and is able to override a subset of the server’s global configuration; the extent of this subset is defined by the web server administrator.

Uses :
1) .htaccess files are often used to specify the security restrictions for the particular directory, hence the filename “access”. The .htaccess file is often accompanied by a .htpasswd file which stores valid usernames and their passwords

2) Servers often use .htaccess to rewrite long, overly comprehensive URLs to shorter and more memorable ones.

3)Use allow/deny to block users by IP address or domain. Also, use to block bad bots, rippers and referrers. Often used to restrict access by Search Engine spiders

4)Changing the page that is shown when a server-side error occurs, for example HTTP 404 Not Found.

5) Enable server-side includes.

6) Directory listing , Control how the server will react when no specific web page is specified.

7) .htaccess files allow a server to control caching by web browsers and proxies to reduce bandwidth usage, server load, and perceived lag.

8 ) Instruct the server how to treat different varying file types.

What is the difference Between array_merge() and array_combine()

array_merge():- array_merge() function Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.
If the input arrays have the same string keys, then the value for that key of first array will overwrite by the value of next array. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be added at the last of the arrray.

array_combine() — Creates an array by using one array as its keys and another for its values