Posted on: 3:28 pm, 19-03-2019

What is PHP?

This entry is part 2 of 3 in the series Build your own CMS

So to start off you’ll have to know why we can only use PHP for this and not Javascript. Javascript and PHP are both programming languages, but the difference is that Javascript (JS) is executed client-side, and PHP is executed server-side. This means that when you load a website in your browser that contains JS, let’s say: https://isittuesday.tk/, the JS code is executed on your machine, and your machine only. On this particular website it checks whether your system is set to a certain day and then according to that day it hides and shows specific elements of the website. Something similar might be possible to program in PHP, but if this is the case then the execution of the code happens on the server instead of your computer. PHP can then output some data to readable HTML code so that you can see it, but the functions are only excecuted on the server side and are thus invisible for the visitor. At first glance this might seem useless, but this comes with a few advantages.

The first advantage is that this allows PHP to execute code that can alter the files on the server. This can be done by using some built-in PHP functions. You could think of it as the CMD promt on you Windows machine. There are commands that can create directories, change filenames, compress images and all kinds of other stuff that directly alters the content of the directories of your website.

The second advantage is that the PHP code is not visible for visitors of your website. The code is only executed on the server. When you visit the aforementioned website, you can right click and inspect element. This shows you the source code of the website, including a little Javascript.

Javascript

You will never find a piece of PHP code by inspecting the website element (unless someone fucked up the syntax). The code that is executed is invisible for the visitor, which is quite convenient since we are going to need to store a password in our PHP code.



« | »

Leave a Reply

Your email address will not be published. Required fields are marked *