Server-Side Scripting

Server-side PHP scripts execute on the web server

mla apa chicago
Your Citation
Bradley, Angela. "Server-Side Scripting." ThoughtCo, Aug. 21, 2017, Bradley, Angela. (2017, August 21). Server-Side Scripting. Retrieved from Bradley, Angela. "Server-Side Scripting." ThoughtCo. (accessed October 22, 2017).

Server-side scripting as it relates to web pages usually refers to PHP code that is executed on the web server before the data is passed to the user's browser. In the case of PHP, all PHP code is executed server-side and no PHP code ever reaches the user. After the PHP code is executed, the information it outputs is embedded in the HTML, which is sent to the viewer's web browser.

One way to see this in action is to open one of your PHP pages in a web browser and then choose the "'View Source" option.

You see the HTML, but no PHP code. The result of the PHP code is there because it is embedded in the HTML on the server before the web page is delivered to the browser.

Example PHP Code and Result


While the server-side PHP file may contain all the code above, the source code and your browser only display the following information:

My cat Spot and my dog Clif like to play together.

Server-Side Scripting vs. Client-Side Scripting

PHP isn't the only code that involves server-side scripting, and server-side scripting isn't limited to websites. Other server-side programming languages are Python, Ruby, C#, C++ and Java. There are many instances of server-side scripting, which provides a customized experience for users.

In comparison, client-side scripting operates with embedded scripts—JavaScript is the most familiar—that are sent from the web server to a user's computer. All the client-side script processing takes place in a web browser on the end user's computer.

Some users disable client-side scripting due to security concerns.