PHP is the most popular scripting language for developing a dynamic website. A dynamic website is one whose page content may vary according to the various variables read by the server. Examples of such variables are,
Consider the case of a bulletin board website; until a user logged in he or she will access limited features and contents which is allocated to a guest visitor. But whenever logged in with his unique user name and password the same URL will provide him few more information which is user specific. Those information may be a welcome message, personal message (PM) arrived at his inbox, when last visited, link to submit a new story, etc. In this example we see that the content of a webpage is varying according to the user browsing the website. So this is an example of dynamic website.
Web pages developed by HTML script are said as static WebPages. You can't vary the page content by using HTML script. This script only can format your webpage content, i.e. making bold text, create tabulated data, etc. Although you can use JavaScript to produce dynamic effect but there are several limitations.
So use of JavaScript is mainly limited in decorating WebPages or to alarm users with an event. But a full function dynamic website should handle form data submitted by the users, handle cookie, access remote database, handle file upload, etc. PHP is a server side language which can do all those jobs very successfully and accordingly it generates necessary HTML code which then reaches to the client computer. In this way the static HTML script itself varies according to the data processed by the PHP server there by producing a dynamic effect at the client computer.
Although there are several other languages like, ASP, JSP, .NET, Ruby on Rails, etc. which can successfully built a dynamic website but PHP has several advantages for which it is the most popular choice among the web developers in building a dynamic website. These advantages are,