Notifications
Article
Client Side vs. Server Side
Published 5 months ago
270
0
Is PHP server side or client side
Website scripts keep running in one of two places – the client side, also called the front-end, or the server side, additionally called the back-end. The client of a website refers to the web browser that is seeing it. The server of a website is, of course, obviously, the server that hosts it.
Most web coding languages are designed to keep running on either the server side or the client side. This largely defines how they work. Here are a few examples.

Client Side Languages

The development of the client side is made almost exclusively in JavaScript. This is, obviously, in addition to essential HTML and CSS code. The reason JavaScript is known as a client side language is because it runs scripts on your computer after you’ve loaded a web page.
Here’s an example:
<script>
document.getElementById('hello').innerHTML = 'Hello';
</script>
That JavaScript code takes the string ‘Hello’ and pops it into the element with an ID of ‘hello’ – suppose it was a <h1>. What was initially inside that element gets replaced, but if you open up the source code of that page, you'll see that unique content and not ‘Hello’.
This is because ‘Hello, world!’ was dynamically added to the HTML document – it was not a part of the original document that was loaded by your browser. However, what you can see is the JavaScript code that was run by your computer.

Server Side Languages

Before loading HTML, server side or back-end language runs its script, not after that. There are a scope of server side languages in use on the web today. PHP is one of the most famous, just as Ruby on Rails, ASP.NET and numerous others. They are called server-side languages ​​because their scripts run on your computer, rather than on the server that hosts the website and sends the HTML code.

Consider this PHP code:

<h1 id="hello"><?php echo 'Hello'; ?></h1>
This code has the exact same effect as the JavaScript code we looked at in the previous section. It puts the string ‘Hello, world!’ into the <h1> element with an ID of ‘hello’. But see the HTML source and what you see is a different story. Inside the <h1> tags will be the string ‘Hello’.
On the other hand, the PHP code run by the server will not be seen anywhere. This is because the server has already taken care of PHP, and what is sent to your computer is the resulting pure HTML.
Conclusion
Most sites make use of both a server side and client side language. Although there are things both can do, there are a few things which must be done server side, and there are a few things which must be done client side.
Front-end scripting is useful for anything that requires user interaction, such as a simple game. Back-end scripting is good for anything that requires dynamic data to be loaded, such as a notice that tells the client they're signed in.
To write your own front-end and back-end scripts, you should learn web development and PHP training in Chandigarh.
Pratibha Sharma
English Speaking Course in Chandigarh - Marketer
30
Comments