Basics of PHP


Some Backstory

PHP is an incredibly useful programming language that leans towards powerful script based web development. If you dig deep into the documentation of PHP, you can find that PHP was originally written to be a visiting tracker for Rasmus Lerdorf's Resume page. Overtime, Rasmus expanded the model to be capable of interacting with web servers, databases and led to PHP becoming a common tool for development of simple dynamic applications such as active lists, submission portals, etc. Formally today, PHP is an acronym that stands for "Hypertext Preprocessor".


So how exactly does it work?

All scripts that are written on PHP are executed onto a server. For example, if you are using a UTCS lab machine to host your webpage, by default, when a PHP script is uploaded to your public_html file, dependent on how the script is set up in the directories, it will use the UTCS server to execute the script. The key idea to keep in mind is that the directory that holds the script MUST BE recursively chmodded to 777 (meaning readable, writable and executable). The reason for this is that the .php file has the permissions to do any neccesary tasks such as generate files.

What is the structure of a PHP file?

  • This permits you to use any element in HTML like < html > , < a > , < li > , < body > , < footer > , < head > , < header > , < img > and the list goes on.
  • HTML Code
    CSS Code
    JavaScript Code
    PHP Code