Author: | |
Website: | |
Page title: | |
URL: | |
Published: | |
Last revised: | |
Accessed: |
Server-side scripts are discrete blocks of program code that execute on a web server (as opposed to a web client) computer. They are generally used to create dynamic web pages. This means that the page displayed to the user does not exist as a document on the server in its own right, and is only brought into existence in response to a user request. Often, a server-side script provides acts as the intermediary between a web-based user interface and a database that resides on a web server.
Early server-side scripts were almost always C programs, Perl scripts or shell scripts which were accessed via the Common Gateway Interface (CGI). Today these scripts, together with scripts created in more recent web application programming environments such as ASP.NET or PHP, can be executed directly by the web server itself, or through the use of server extensions. The scripting languages used to create the server-side scripts behind many of today's web applications include ASP.NET, ColdFusion, Java, Perl, PHP, Python, and Ruby. Almost all client-side scripts are written in an ECMAScript-compliant language - usually JavaScript.
For dynamically generated web content, shifting as much of the processing work as possible onto the server has the advantage of speeding up page rendering at the client end because all of the HTML, CSS and JavaScript code has been generated on the server. On the other hand, every additional request sent to the server will add to the server’s overall workload. It will also inevitably involve some delay, because both the client request and the response from the server must be sent back and forth over a network. These are factors that developers need to take into account when designing web applications.
To be clear, both server-side and client-side scripts can be used to generate content dynamically. Both PHP and JavaScript, for example, can generate the HTML and CSS code used by a browser to render a web page. The difference is that PHP generates that code on the server before it is sent to the client, whereas JavaScript (usually) generates the code on the client computer. There is also usually a fairly clear distinction between the kind of tasks that should be carried out on the server and those best left to the client computer to perform.
Client-side scripting is typically used to enhance the user interface by providing effective feedback in response to user actions, and for validating form data input by the user before it is submitted to the web server. Client-side scripts cannot directly access the client computer’s file system, although a user may grant read only access to a local file if a web page contains an HTML <input type="file"> element.
Tasks such as validating user credentials, querying a database, monitoring user activity over time (session management), and the server-side validation of user input must be handled by a server-side script. The code that carries out such tasks is hidden from the end user and executed in a controlled environment, providing a measure of security. Server-side scripts are generally responsible for data processing and management tasks on the server, including the analysis of user data in order to provide the user with content likely to be of specific interest to them.
A web application framework (or just web framework) is a software framework designed to facilitate and support the development of web applications using a specific server-side scripting language. Such frameworks provide a development environment within which the tasks involved in creating and deploying a web application can be carried out in an optimal manner, maximising developer productivity, streamlining the production process, promoting teamwork, and enhancing the scalability and maintainability of web applications.
Web frameworks typically provide a set of built-in components and code libraries that implement common server functionality, such as database access, session management, and user authentication. Examples include ASP.NET, Django (Python), Laravel (PHP), Ruby on Rails (Ruby), and Google Web Toolkit (Java). The choice of framework thus depends in part on the target scripting language, as well as on the requirements of the application.
Using a web framework is highly recommended for larger web development projects, although the choice of both the scripting language and the web framework to be used in a corporate setting will be dictated by organisational policies rather than by an individual developer. For small projects, particularly projects that are undertaken by a single developer, the use of a web framework could introduce unnecessary complexity into the development process.
PHP is a widely-used and open-source server-side scripting language originally created by Rasmus Lerdorf in 1995, and now maintained by the PHP Group. PHP originally stood for Personal Home Pages, although the acronym is now understood to stand (somewhat recursively) for PHP: Hypertext Preprocessor. PHP is free software released under the PHP License, and is especially suited to web development.
In these pages we will be using PHP to explore the world of server-side scripting. Despite a slight decline in popularity in recent years, PHP is still the most widely used server-side scripting language by a very wide margin, with a market share currently of around 75% - and it’s completely free to use! The current stable version of PHP at the time of writing (June 2025) is PHP 8.4.8.
PHP is frequently used together with MySQL, and is one of the key technologies in the XAMPP (Cross-Platform, Apache, MySQL, PHP, and Perl) web application architecture. We will be describing how you can set up a local server on your PC or laptop using XAMPP (which is also completely free!) in a separate article in this section.