From the course: Learning PHP

How PHP works - PHP Tutorial

From the course: Learning PHP

Start my 1-month free trial

How PHP works

- [Joe] PHP stands for PHP Hypertext Processor, it's a recursive acronym. But basically it's a programming language that allows you to add dynamic and backend functionality to your website. It's often used for tasks that a markup language like HTML can perform; processing forms, talking to a database, creating secure areas, reading from a text file and more. PHP is a server-side language, meaning our server or remote computer does all of the work and then sends the end results to our browsers. You can imagine the process like a translator. The server translates the PHP into a language our browsers can understand. In other words, PHP allows you to apply logic and perform interactive tasks based on a set of criteria. HTML strictly structures the data on a page. HTML, CSS and JavaScript are also client-side languages, meaning our computers, specifically a web browser, does all of the processing, and we can see all the code. That's not the case for PHP. The strong benefit of that is that you can write more secure code. Since not everything is exposed in the browser, you don't have to worry about showing passwords or other sensitive data. You can retrieve and sanitize data before sending it to the browser. The server knows which files use PHP because they end in .PHP, much like HTML files and in .HTML. The server takes the PHP files, processes them, and sends only the output to the browser. Further, the server knows only to process the PHP code. That code will be between opening PHP tags and closing PHP tags. The rest will be treated as plain text or HTML. Because of this, you will see HTML and PHP commingling in the same files a lot. But remember, while HTML can go into PHP files, PHP cannot go into HTML files. Now that you know a little bit of how PHP works, let's start using it.

Contents