Locked lesson.
About this lesson
Understanding the Fundamentals of PHP and the client/server relationship.
Exercise files
Download this lesson’s related exercise files.
How Does PHP Work?.docx58.6 KB How Does PHP Work? - Solution.docx
58.7 KB
Quick reference
How Does PHP Work?
PHP is a server-side scripting language.
When to use
PHP is great for front-end web development.
Instructions
PHP code is written on a web page, but executed on the server.
PHP code is written inside a PHP tag that looks like this:
<?php
?>
<?php is the openeing tag, and ?> is the closing tag.
PHP statements end in a semi-colon.
Hints & tips
- PHP is a server-side scripting language.
- PHP code goes inside this tag: <?php ?>
- PHP statements end with a semicolon
- 00:05 In this video I wanna spend just a couple of minutes talking about PHP, what it is,
- 00:09 how to use it, that sort of thing.
- 00:10 So PHP is what we call a server side scripting language.
- 00:14 And the difference between server side and client side is pretty dramatic.
- 00:19 And it really kind of defines a lot about PHP.
- 00:22 A lot of front-end web developers will use JavaScript or PHP.
- 00:26 Now JavaScript is a client-side development tool, PHP is a server-side.
- 00:30 So what's the difference between that?
- 00:31 Well if you go to any website, let's go to GoSkills.com.
- 00:34 And if you right-click and click the view page source,
- 00:38 you can see the actual HTML and CSS that's used to create this webpage.
- 00:42 And if you look around here on a lot of websites, you can also see,
- 00:46 like right here, this is JavaScript.
- 00:47 And this is right on the page itself, right on the HTML.
- 00:51 And this gets executed right in your web browser.
- 00:53 That's a client-side programming language, it gets executed on the client-side.
- 00:58 PHP is a little bit different.
- 00:59 We actually write PHP code on an HTML page, but
- 01:03 it actually gets executed on the web server back up in the Internet somewhere.
- 01:07 And there's lots of different web servers,
- 01:09 we're not gonna get into that in this video or this course.
- 01:11 But Apache is one of the most popular web servers, PHP runs on Apache,
- 01:15 it runs on every web server, basically.
- 01:17 So that's sort of a distinction to understand, you may not understand exactly
- 01:20 what that means at this point, you'll start to understand that later on.
- 01:23 And in the next couple of videos, we'll show you how to setup PHP and
- 01:27 get in running, so that we can use it on a web server.
- 01:30 But that's sort of an important thing to understand.
- 01:33 Next, I wanna spend just a minute talking about how to actually write PHP code.
- 01:37 And PHP code is a little bit different, and
- 01:39 we'll get into this a little bit later.
- 01:40 But like I said, you write your PHP code right on an HTML page,
- 01:44 right in your HTML document.
- 01:46 And to use PHP on a website, we use these opening and closing brackets.
- 01:52 And it starts with a question mark and PHP, and it ends with the question mark.
- 01:57 So this is a common PHP tag, just like this.
- 02:01 And I've just got a Sublime text editor open right now.
- 02:04 This doesn't really matter, you can use any sort of text editor you want.
- 02:07 And we'll get into that later on, but just for purposes of showing you this.
- 02:10 Anything we write in between these opening and closing tags is gonna be our PHP.
- 02:16 So we could type in echo Hello World,
- 02:21 put a semicolon and this is valid normal PHP.
- 02:26 And like I said this gets executed up on a web server, but
- 02:29 it gets written on your HTML page.
- 02:31 A little bit confusing, but
- 02:32 what happens is when the webpage loads it sees this tag.
- 02:35 It notices, hey this is PHP.
- 02:37 It calls back to the server and executes this thing and
- 02:40 then the server replies with whatever return your code suggests and
- 02:45 then it prints this out onto the screen.
- 02:47 So it may be a little confusing at first as we start to use this it will get
- 02:50 very clear what I'm talking about, but that's the main designation.
- 02:53 The main thing that sets PHP apart from other languages, like JavaScript,
- 02:57 is that PHP gets executed on the web server on the server-side,
- 03:01 as opposed to the clients side.
- 03:03 So in the next video we're gonna talk about setting up a local development
- 03:05 environment on windows.
Lesson notes are only available for subscribers.