PHP Crash Course | Kalob Taulien | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
25 Lessons (1h 18m)
    • 1. Introduction Video

      1:09
    • 2. Introduction and Installing XAMPP

      3:50
    • 3. Creating your first PHP file

      2:52
    • 4. What is PHP?

      1:29
    • 5. Who uses PHP?

      1:33
    • 6. Syntax

      1:26
    • 7. Variables

      1:39
    • 8. Echo / Print

      2:47
    • 9. Code Comments

      1:47
    • 10. Quotes vs. Apostrophes

      1:57
    • 11. Data Types

      3:42
    • 12. Strings

      1:42
    • 13. Constant

      3:10
    • 14. Arrays

      4:34
    • 15. Loops

      6:26
    • 16. Multidimensional Arrays

      2:37
    • 17. Conditional IF Statements

      3:59
    • 18. Else Statements

      1:17
    • 19. Comparison Operators

      1:40
    • 20. Switch Statements

      3:21
    • 21. Functions

      14:13
    • 22. Super Global Variables

      3:33
    • 23. Forms

      2:38
    • 24. POST Forms

      2:56
    • 25. Summary

      2:02

About This Class

In this course you will learn about:

  • PHP as a web development language
  • Who uses PHP
  • How to install PHP
  • What a .php file is
  • PHP Syntax
  • Echo / Print
  • The print_r function
  • Variables
  • Data Types
  • If/else Statements
  • Switch Statements
  • Functions¬†
  • Super Global Variables
  • How to accept user input from a form.

abe56011

Transcripts

1. Introduction Video: Hello. Welcome. If you're interested in learning PHP, this is probably a good course to start with house courses for beginners or someone who just wants to learn a little bit more about PHP. Ah, it is a crash course. So you're going to learn a lot of information. They're going to absorb a lot of knowledge and about 80 minutes, and you're going to learn everything from variables to who uses PHP to how to install PHP on your laptop, Um, and how to write PHP functions, variables. If statements condition ALS, you're going to learn about all this stuff. And then at the end, you're going to learn how to take a form and actually use some user input in your application. Now, if that sounds great to you, then feel free to step inside. But if you're looking for a course, that's 19 hours, 20 hours long boat PHP. Unfortunately, this is not the course for you again. This is just a crash course. This will get your your feet wet. This will get you some immediate experience with PHP and all in less than an hour and 1/2. So again, if that's always great to you, feel free to step inside and we'll get started right away. 2. Introduction and Installing XAMPP: Hello. Welcome to a PHP crash course presented by yours truly. Caleb Tallinn. And I guess sponsored by Caleb dot io, which I guess my own sites have not really sponsored. But in this video and Siris of videos, depending what platform you're watching on, we're going to be learning all about PHP. And this is a crash course. So this is going to be relatively fast. If you need to stop Google something, rewatch it. I'm not going to slow down for a whole lot. But we are going to get started right away, and we're going to go through everything from installation to variables to functions and all that stuff. So it should be very, very quick if you're expecting a 19 our in depth PHP course. I'm sorry. This is not it. This is literally a PHP crash course. All right, so the first thing that you want to do is you want to open up chrome or Firefox or opera or whatever browser and you want to type in download. Samp X a MPP. It's by Apache friends. You go in here and you can just download whichever one is good for you. We want to use at least something with PHP. Version seven eso I'm on a Mac. If you're on Windows, download the windows version. If you're on a Mac down with the Mac version or I mean, I guess if you're on Lennox, you can download Lennox version as well. Eso I'm gonna download the Mac one, and I'm gonna go with Let's go with PHP 7.2 point six. So I download the 64 bit one and it's going to download. All right, that's downloaded. Been. Open that up. Okay, so I'm gonna just drag this due to do No, not rename there. Go drag it to my applications. Go in my applications. There we go. We have it and type in example. And this is just going to look for my exam PTA, DMG file. If you're on a Mac, all you have to do is drag this exam taught ap into and to here. I'm gonna get rid of this DMG file because I don't need it. And now that's a well. It's ready to be installed. Type in, not camp, but zump dot a PP. If you're on windows, you just need to install the e X e file. Yeah, I'm gonna trust this. It's gonna ask me for my password, and then it will begin installing bit nanny. OK, so it next, if these are not checked to make sure they are checked, hit next. Next. Next it opens up this advertisement for bitten at me. Whatever. Go back to your installer. Hit next. Okay, so this is just finishing up here. It's saying, welcome to Sam. But now me, for example, blah, blah, blah. You can see that it supports WordPress. Truthful all sorts of things in here. Okay, so I just fast forwarded their Ah, I apologize. If you can hear is a fan of my computer background. It's recording video and audio and installing doing all this other stuff s so I apologize for that. So it says launches, amp, we're gonna say finish, it's launching. Its gonna bring us to this. Weird you out that if we click up here, they go see Caleb's Mac book pro dot local slash dashboard, which, if you're on any other computer, are really any computer. Just goto local host this type in local host. Or if you like to use chrome, you can just go to Http. Ah, to do not s http Colon Colon, local host, and it brings us straight to dashboard. Okay, so now we have zap installed, we can start using PHP. Uh, you want to look at some PHP info, go to PHP Info. This is literally a PHP and full function, and its has tons of information in here. So if anyone ever asked questions about, like, databases or PDO or what version of PHP you're using, this is the file you want to look at. 3. Creating your first PHP file: Okay, so now we need to create our first PHP file. So what? We need to dio Ah, but up, up, Let's go to at applications, go to Samp, and then we need to go to exempt files. Or we can go to H C docks, which is a short cut, but we go to zap files, I will CHD docks in here as well, and this one should ideally not be owned by you. So there are user permissions. We're gonna have to go in here. Um, and this this may or may not affect your computer, but it does definitely affect my computer. So what we're gonna do is gonna go to get info. We're going to unlock this. It's asked for my password or my fingerprint system. Admin can write system it system can write this system, and men can write, Um, and everybody can read only. So I'm going to change us toe reading, right? Lock that back up. And that just allows us to create new files in here. So now I'm gonna open up sublime. You can use Adam V s code. Whatever editor you want, I'm gonna open up that whole directory. Go to applications. Go to HD docks open. Cool. So we got a bunch of stuff in my sidebar here who had applications, but now me dot CSS blah, blah, blah index dot PHP. And this looks like it's automatically going to our dashboard. Now, if you don't know what that code looks like, that's totally okay. It's just this. So if I was to go in here to leave this, save it, refresh this page, nothing's gonna show. That's everything in a show. But if I go here, nothing's gonna show up because it wasn't redirecting the perfect. So now let's just do this. Let's do basic H e mail. Hello, world The de facto. Hey, we are writing code. I refresh my page. Boom! It says hello world. Okay, so this means that you have PHP installing. If you really want to test it, you can simply do when Zack making this bigger echo test. Don't worry about what all of this junk looks like right now. I'll explain all of it. It says testing here. I'm gonna make that bigger, too sweet. So you now have pH be installed using a Samp server. If you're on Windows, I apologize, But you have to figure out some of the stuff on your own, I think. But generally, if you go into your C drive and then it's like Samp on, I think the folder you want is HD docks. So I think it's something along these lines. HD docks. This is where your folder is gonna be. It may possibly just be an HD docks somewhere around there. I take a look for that's where we're going to be putting our PHP files. If you get stuck urine windows or you're on Lennox, give it a quick, YouTube quick Google. There are tons of supporting articles out there, a lot of videos that can help you get started with Samp. 4. What is PHP?: Okay, so let's talk about what is PHP? PHP is a pre processor for hypertext. Essentially. What that means is we can write HTML and PHP together as what Apache will do. What PHP will do is it will try to read and render that code and spit it out as if it was HTML and I'll show you a little example here. So if we type and again, don't worry about this syntax here. Sin taxes, like how we how we write the actual code. Hello world. So now we have PHP mixed with HTML. Now one of the cool things is if we go and inspect our page, it just shows up down here with hello world. May God bigger as well. That's all it says. Hello world. It doesn't show us our PHP. PHP is effectively hidden from the world. It is a server side language, meaning it runs on the server. It turns everything into text, or HTML or whatever you need it to be. And then it will go ahead and spit it out as if it's regular, each email or texture or anything that you would normally right. Even CSS and JavaScript and always see is regular document object model stuff. Cool. So PHP that's essentially what it is. You can mix html in PHP. It's a server side language. It's a back end. Language is not the same as JavaScript Rhe Miller CSS. 5. Who uses PHP?: and now on to who uses PHP. This is a great question. Who uses PHP? I mean, really, who even uses PHP now? A lot of people say that PHP is dead. Ah, there actually, super wrong Ph. B is growing. PHP is growing faster and faster and faster. And at this point, it's actually I mean, I have made a PHP course not that long ago, um and always saying that it was think 27 or 28% of all websites were running WordPress, which uses PHP which, by the way, let's just write that down. WordPress equals PHP. It's now up to 30%. It might even be 31% at this point. That does not include June live Inna. That does not include custom applications that does not include APS, Lake, Facebook, Yahoo. If you remember that company, they sort of went under. But they use a lot of PHP as well. A lot of websites use PHP a lot of Dev's use PHP all of WordPress uses PHP over 1/3 of all websites on the Internet. Over 33% of all websites air using P a tree and that number is getting higher and higher. So next time someone says no, don't learn PHP flor Note. I'm gonna tell you right now. While that may be good advice, it is not great advice. And that's because PHP has so much demand out there right now that it would be it would be irresponsible to not learn it if you're looking for a job if you're looking to freelance, if you're looking to make extra money as a Web developer, change careers, learn PHP. 6. Syntax: All right, let's take a look at some basic syntax. So sin taxes effectively. How we actually write some of our code here. Just get rid of this stuff here. Did it make some room for us? I got a little bigger. Okay, So sin Taxes. Whenever we write PHP code, we need to open it with a less than sign question mark and then PHP. That just means that everything in here is going to be PHP. And we always end it with a question mark and a greater than sign that is always PHP just that's what we do. That's how the server knows To interpret this as PHP and not just regular HTML or JavaScript, CSS or anything like that quickly run through a few things here. Variables always start with a dollar sign. We'll talk more about variables in a bit. Ah, strings, which is a data type. We'll talk more about those in a little bit as well. Always have quotations or apostrophes every line. Every line ends with a semi colon. If you come from python or javascript, there's no such thing as dot notation, so it wouldn't be like name dot split that does not exist in Ph. B. Instead, we would do split name, so everything is function based. And by that I mean, I'm not saying that is not object based. There is, ah lot of object orientated PHP out there, but we're not talking about that right now. We're just talking about essentially how this works, so there's no dot notation. 7. Variables: All right, let's talk about variables, variables, which I mentioned like a minute ago. They always start with a dollar sign. Um, they should never, ever start with a number after the dollar sign. They should never really start with any sort of special characters. You can see that my editors changing the color what it should start with is either an upper case or lower case number or an underscore. So I could say name, lips, name or name something like that. Now a variable is an assignment. So it's were saying that this variable Whenever we references later, we'll get into this very, very shortly. This variable is representing Caleb calling. It's just my no big deal now. This won't work because I'm missing one of the rules. One of the main rooms of PHP Sin taxes. Every line has to end with a semicolon. Every statement actually has to end with a semicolon because we could keep writing code in here, which technically would go right across this line if I didn't have word wrapping turned on in my editor. And so this is a variable. Now we can also have other types of variables data types We're going to get into this very shortly. I promise. So, uh, age? For whatever reason, I just typed 13 age 29. That's actually wrong. I'm 28 stale 29 soon enough. And we saved that. If we refresh your page, nothing shows up. There's nothing in here. That's because all PHP did was say, I'm setting a variable. There's a value in here. We're using the equal sign to set those variables, but we haven't actually displayed it. 8. Echo / Print: All right, let's talk about echo and printing. If you come from any other programming language, there is a way to print. It fits in python. It's print if its in python to its print. Something here, if you're in javascript is often consul dot log or nope, or document dot Right in PHP. We have two methods. We've got prints, and we also have echo, uh, generally speaking, PHP developers. Don't you sprint? We tend to stick with the word echo. So what we're gonna do here is Echo name, and all this will do is say my name. Now, if I look at my HTML in here, it just says Caleb telling There's nothing else in there. It just says my name. And if I wanted to change that, I could change that to age, and this will show up as 28 as expected. And so what this is doing is we're referencing this variable this value up here and then we could say this over and over and over and over and over again, and it just says 28 over and over and over again. So this is how we echo to a page now there's something called concatenation Now, if again you come from Ah, python or JavaScript background. Concatenation is the idea of of adding sentences together or adding bits of a sentence together. So we can at another very bowling here called sentence. And this one is Ah, let's say name and PHP we do it with a dot This is called concatenation. I'll write that down con Cat nation. By the way, it took me years to be able to say that word. I couldn't say it for the longest time. So what we're saying is name is my name. I said Michael and save ask me for my password just because I don't usually use Samp. Um and I don't have my permissions properly set up. You can go ahead and change your permissions on there if it keeps asking for your password again. So I refresh my page Walla. It says nothing because I haven't echoed anything back to the page yet. So I echo sentence. Caleb, Italian is my name, and we see that in our source. And if we actually want to look at the proper source code view page source. Boom, There it is. So this is called concatenation. In JavaScript, we use the plus sign in python. Sometimes there's a plus side, or we just can't Katyn eight strings just by, um, just by adding, like one string here, another string separated by a space. Sometimes in JavaScript, we use the dot join method dot joint function in PHP. All we do is the dot Now there's another way to add sentences together, and that is through single or double quotes. We're going to talk about that. 9. Code Comments: a very shortly. But first I want to talk about comments. So what you saw? I'm gonna undo a bunch of stuff here. Do do, do get rid of that. This is called a code comment. So this doesn't show up anywhere. So even if I said echo, show me and refresh my page And you know what? Let's let's take a look at I just want to see my source. There we go. It wasn't Let me select my source there. It doesn't show Echo. Show me in here now. The reason for that is because we're commenting. The Kodo comments are a great way to keep track of your code to make notes in your code, to tell yourself or other developers what you've been working on, how things work. Um, what data types variable should be again. We'll talk about data types very, very soon in PHP. There three types of comments. There is the single line comment that starts with. If you haven't noticed, it starts with two slashes, then there's another single line comment and just starts with what looks like the hashtag or the pound symbol. It's the number sign another comment, and then We've got a multi line comment and this one can comment out multiple lines, and all we do is we type a slash an asterisk, and then we can type literally anything in here for a long as we want, and we end it with asterisk slash. So just the opposite Refresh my page. Well, I save. And then I refreshed my page because just refreshing is gonna do anything. I'll do even refresh a source. Nothing happens. None of this stuff will show up, and that is simply how you comment out your coat. So there are three ways to commenting. Your code double slash You can use the number sign hashtag whatever you wanna call it these days. And then there's the multi line, which is the slash with an asterisk and ends with an asterisk slash. 10. Quotes vs. Apostrophes: next. Let's talk about Ah, I guess we actually what I mention little bit earlier. Single verse, double quotes. Okay, so we've got a sentence here. We can also, by the way, with variables weekend overwrites, other variables. Cool, Cool. So we can say I'll just show you sentence. So this sentence here is what worked a little bit earlier and I'm overriding it. And when I refresh my page, it just as test. And that's because effectively, this one was over. Written by this one which has a value of test. No, if you've noticed, I've been using quotations. But we can also use single quotes as well. So I'm gonna get rid of some of this just to clean this up and echo. Hello World and boom. Hello world. Now there's literally no difference when I use quotations versus apostrophes. The difference is when I want to echo of variable so I can say hello world. My name is and I just typed my name in here. You notice that it's just dollar sign Name is referencing this variable directly inside of this. Hello. My name is Caleb telling now if I didn't want to write that if For whatever reason, I actually wanted to write Dollar Sign name as if I was writing articles about code about PHP. I would change those quotations. Two apostrophes refresh my page and there we go. So those air called magic quotes. And whenever you want to put a variable inside of a sentence, you should always use magic quotes, and you can can cat need these as well? And but its base in there and my age is age save refresh. Hello world. My name's Kayla battalion and my age is 28. I am so there you go. Now you know the difference between a pasta freeze and quotations. A lot of other languages don't support that. PHP does. It's very cool. 11. Data Types: Okay, let's talk about data types. I've mentioned this a few times already. Caleb, what the heck is a data type? Now, if you've got no programming background experience, anything like that, you've never in JavaScript are python or ruby or C or Java or anything like that. Guess what? That's totally okay. I'm gonna tell you something that you may not completely grasp. And at this point in time, that's acceptable. Don't worry about it. The big thing here that the big take away is that you know what these are. Okay, so the 1st 1 here, variable name is equal to Caleb telling this is called a string. So this one is a string. And the reason it's a string is because it has quotations around it or apostrophes around it. That means it's a string and we can also put spaces in it. We could put literally any character we want in there. The next one age is equal to 28. You notice how there are no quotations. There are no apostrophes. There's nothing around it. It's just the number. This one is called an integer or into for short. Now, if we wanted to get a lot more specific. With that edge. There's another one called afloat in some other languages, is also called decimal sa mo. There were learning to spell, and we could say age exact is equal to 28.75 So what afloat is means there it means there's a floating decimal point, so this in math assumes that's 28.0 is the same as 28 so you don't need to write the 280.0 in there. But afloat has has decimal points. Okay, the next one is called a Boolean or a bull, and you will see these all over the place. So a bull is either true or false, so we can type. True, we could also type force, and that's all I can ever be can ever only be true or false. Now there are different ways to represent a Boolean. A Boolean can be zero. That means it's actually changed wrong. When the ah Boolean can be 00 is the same as false and one is eagled, the same as true. Actually, In fact, any number that is not zero is equal to true. Okay, Next we have something called an array. Ah, in some languages, like Python, it's called a list in JavaScript and PHP. It's called an array, and it looks like this. Basically, it's just a list of all of these other data types, or or one day to type over and over again, or just one single variable. But it starts with these hard brackets, and this suggests that it's a list. You could also type it this way as a function, but we're not going to We're gonna take it this way because it's more common. It's also less typing. And we're going to write Name, age, Country. And so what you see here is I'm gonna zoom out. So this looks a little better on one line. So we have a raise equal to well, array. We know that because we've got these brackets in here and then we just have a string. We notice string is comma separated. We've got another string comma. Separated means that there's another one after it. We've got another string, but they don't have to be strings either, right? They could be really anything you want. They could be. So we've got a Boolean we've gotta float and we've got an integer in there, and that is all acceptable. There's one more that we're not going to go over. It's called an object. It has more to do with classes. Inheritance. Um, it's sort of like variables inside of group variables. We're not gonna get into that just because that is a little out of the scope pun intended. But those air data types now you know all about them. 12. Strings: Okay. Now we should learn about strings, So I'm gonna go ahead to leave this. We talked about strings was the 1st 1 Strings have quotations. They've got apostrophes or quotations around them. They can have literally anything. You can have a number in here. You can have a float in here. You can say the word true in here. Assuming that I could spell the word true correctly saving refresh. Nothing happens. But if I type eco name Walla, it just shows everything that's between these quotes. Cool. That's a string. We also know that we can put variables in there. We know from just a couple of minutes ago when I was talking about single quotes, first double quote so we could also put a variable in here. This variable does not exist, so this won't show anything. In fact, it shows me an error. Says undefined. Variable, variable. This is fantastic because this tells us directly what the error is. If there is something running that it cannot figure out, it'll give us in there. And so what this is saying is undefined variable, variable. But if we change us too, anything undefined, variable. Anything. So all that saying is this value this variable does not have a value does not exist. We could set it to literally anything. Just so it shuts up, we say, if we refresh whammo, I could even put whammo in there. Caleb Obama. 123 12.2. Truth telling. Okay, so now we know all about variables and we know that variables equals string into float something I got there's another one. 13. Constant: I. Sometimes you want to set a certain value that's going to run across your entire application, that you can never change. And this is called a constant. Now will Constant that's a constant is a variable that can ever change. It is constantly the same thing. That's how I think about its core instantly the same thing. And we don't define it like we do a variable you think we would, but we don't. In fact, we right define and we put whatever you want to hear. So let's go name, comma and then the value and we say Caleb Colleen. And when I refresh page, you're not gonna see anything because all it did was defined the constant. It's just like defining a variable. It didn't do anything. What we need to do is echo this back to the page tutta. But the problem is, we cannot overwrite this. So whereas we have variables, we could say anything. Echo variables, very ya balls refreshing. It says anything. So this is over written and we can see this if I type over written here and then all of a sudden it's anything it refresh the page. It always just says anything. It's as if this didn't even happen, which is perfect because of variable should be flexible, but a constant should have the same value every single time. And so what I'm going to do I'm using a comment. Here is not only an I going to echo this out to the page, but I'm going to try to redefine it. So if I type name is equal to any other name in the world. So let's type in a crazy name. Protection of the crazy. This is the name of my cat, By the way, is that for a refresh? It has a parse air, it is saying unexpected. Equal sign with that saying is this should not be there, which, technically, is a little bit wrong because it's looking for a variable of variable assignment. It doesn't exist. Even if we throw a variable in here, it's still going to just say killed Colleen. In fact, let's move that down to the bottom. Oh, by the way, PHP runs from top to bottom. Like most programming languages, like C S s like JavaScript like python, it runs from the top to the bottom, so it's gonna execute Ah, this line first and then this one and that one And this one and then that one. So what? We're overriding over right underneath. Like what we did here. Okay, Save, refresh. Nothing happens. And that's because at this point, it's just a variable. We know it's a variable because as a dollar sign in front of it. So if we get rid of it, we get that error. Now. We cannot redefine this. Now. Let's actually try to redefine it. So it's already to find here, and we're going to redefine it in here. Get rid of that stuff. Save, refresh. And it says, constant name already to find an applications Ampersand files eight. She docks index dot PHP. That's exactly where this file is located online eight, which is very helpful. It tells me that this is already defined and that this needs to be gone because Constance cannot be read ified. There you go. You know about variables and constants 14. Arrays: All right, let's talk about a raise, a raise to do or we can do a raise. Those are plural, though, should not be plural, because there you. So we've got two ways of defining an array. We can do this way or this way. I always prefer this way just because oh, they re it's asking me to save us again. I always prefer this way because it's nice. It's very simple, very straightforward. You know, the hard brackets always mean there's going to be a list of values. Now this list of values may only have one thing. It may have nothing in it, but if I do something cool, I'm gonna show you a cool trickier. If I do print are array, refresh my page. It shows me it's Justin Array, but if I've got a value in here, any value, right fight tight Caleb dot io In here, just as a string is first value, his first value is zero, and let's type in another another value. But let's let's make this 1 28 and let's make another string called two cats. I actually have two cats and let's view the page source because this is gonna look much better. Actually, you can see it in our inspector as well. But I like going here because this looks nice. So this is telling me that when we print our that this data type isn't array. Now you're familiar with data types and that the first value is killed that I owe. Second value is 28 3rd value is two cats. So now you may have noticed. Caleb, what the heck? Why is this start with a zero? Why is that? Why is number 10 Number 21 A number three too Well, that's because computers typically start counting at the number zero. Number zero is the number one. For them in inhuman speak, zero means nothing. It means there's nothing there. There's no value. It's no, it's void. But in computer programming, zero is simply a number. It's an integer, or if it's a Boolean, it's considered false. But this one is just saying that the very first value is Caleb dot io. Now, why are list really important? Lists are important because you can loop through them now. Looping is really, really important because basically what a program does, is it grabs a bunch of information, whether it's from a database or from SCS V or some sort of list, and it loops through each item and it performs a particular function or a series of functions on each value. Now, in here, this is considered a value 28 does the value, and two cats is a value. Those are two strings kale dot io and two cats those air strings. And this is an integer, but each of those are considered a ray values. Now, let's look at an associative array. Associative ray is actually so much cooler. So I'm gonna move this on multiple lines. Oh, by the way, in PHP, you get all the white space you want. If you come from python, guess what? You can't do this very easily, but in PHP you can do anything you want. Really? So what we're gonna say is name Fat Arrow is Caleb Tall, lean website Caleb dot io age. Believe me, when I'm done typing, this is gonna look so much better. I promise. And cats two gets. So now what this is saying is this is an associative array. This is something that's fairly unique to PHP. Ah, you don't really see this too often. And now when I refresh my page, you can see that array Name is evil Caleb Italian website killed about Io age 28 blah blah , blah. All we did was instead of that 012 that we saw before we named him. And now we can echo these as well with an echo, an array we could say array name Echo is my name Echo. Let's do array website echo is my website scared of that and go back to her actual page and Walla Caleb telling is my name killed dot io is my website and now instead of array, what we could do is we could change this out for Kale. But now we've got a bunch of variables named Variables all group together. And instead of having to write Caleb name kill of website Caleb age Caleb cats and then adding values to each of these something like that. All we're doing is we're putting it in tow one variable, which is really, really nice 15. Loops: All right, let's talk about loops. There are three primary types of loops there's technically for We're not gonna go over one of them. In fact, the one I'm gonna tell you right now, the one we're not going to go over is called a do wild loop. It's hardly used. You see some scenes, senior programmers use it. We're just not gonna worry about that one right now. I think it's gonna be a little bit too confusing for this crash course. So the 1st 1 we want to learn is called a four loop. The 2nd 1 is called a wild loop, and the 3rd 1 is called a for each loop. So I'm gonna comment those outs and the 1st 1 we're going to learn is the four loop. In fact, I would like to number those Helps us keep track. Okay. Number 14 loop. What we're saying here is for a certain amount of time, loop through things. So, for we're just going to set some sort of variable, say I for it. Aeration is equal to zero. Ah, this should loop through this for as long as I is less than the number 10 we'll talk about this last, then sign and a little bit when we talk about, like, math and arithmetic and things like that. And after every loop cycle, we're going to increase by one. Okay, so first thing first that increased by one looks pretty weird. What this means is I is equal to I plus one. That's all that means comment that out. And you can look at that. I guess while I'm talking baby and we're gonna type Echo and can Captain eight a line break in there. Save, refresh. And it says 0 to 9. Awesome. In fact, we don't even need to contaminate that. Really. We just threw that right in there because we're using double quotations or double bus trees . Regular quotations, chur. Anyways, so it says line 0123456789 Great. This is a loop. And after each one weekend, we can tell it to do something we can say at line five if I is equal to five Echo, this is line five, and that complains because I broke my own syntax rule. What I'm looking to do here is at a semi colon, blah, blah blah. There we go. 1234 This is lying. 56789 Great! That is a for loop. At this point time, you're probably thinking, Caleb, why the heck would ever use that? Well, what if you wanted to create 10 users and 10 test users in your account? Instead of running one script 10 times or copy and pasting 10 times, you can write well, your regular create user script. In here, you can write a few lines of creating your own user, and then you can basically just write this line and close your for loop and boom, it does it for you, just like that. So that's a four loop. Ah, wild loop is essentially a four loop, but it's a lot more manual. So Ah, Wild Loop, while numb is less than 10 is going to do some stuff in here. The problem is, this is going to go on forever because actually is not going to run it all because numb isn't set. But if we said numb is equal to zero, it's an integer, so we know that it can increase. At the end of this, we can say none plus plus. And what this is going to say is this starts at zero. It's going to iterating until it gets to whatever number is less than 10 while this is less than 10. So it's gonna be nine and after each generation increased by one. So if we said echo line numb, upend a little line break in their refresh line. 0123456789 and just so that you can see that it is something different while loop line. There you go while loop line one through nine. Now don't forget to add your incremental ER or decker mentor or whatever will break out of this loop, because if you don't add this and you run the script, it could possibly run forever now. PHP. Generally, let's a script run for about 64 megabytes by default, which can be a whole long time, depending on what year what your script includes. The script has almost no information it. This could run for a very, very long time. I'm not going to do it because I don't want to. Well, no, it's just that I don't want to, and nor do you because that's just gonna kill your script. It's gonna take a while. Just don't do it. Just remember, you always need something to break out of this condition. So what this is saying is, while this condition is true, execute this code after each generation, This gets up to line nine. Once it gets up to number 10 it is saying if 10 is less than 10 do this Code 10 is not less than 10. 10 is equal to 10. It does not execute the code anymore. Moving on. Okay, The next one is called a four each loop as close that down a four each loop is probably the most common one because you can loop through an array and it just takes care of everything for you. So the first thing we're going to do is type for each What are we looping through? Let's loop through the Caleb array. We see that up here. This is our list. We use the the key word as and then key, thou vow Ah, ah, vow is equal to value. It's just a short wave. Put again. Um, and what we're going to do is we're going to echo every key and every value. So echo que Val and put a line break in there, and this is going to print out our entire array. Look, says my name, my website cats. Basically, it did what print our did for me. But unlike the four loop, we didn't have to tell it to go for 10 loops. 10 cycles, unlike the while loop. We also didn't have to set that or set it manually and in the for each loop, it just loops through all of these Walla. Once it's done, it's done. We didn't have to worry about a memory leak or anything like that. It just loops through the values in here. This one is very, very popular in PHP, so get used this in tax. Now there's another way we could do this. We can loop through each instead of having the key and the value. So in Associative Ray, this is called key. This is called the Value. We could just say Val, and when I refresh, it gives me and find variable key because he does not exist. So let's go ahead. Let's get rid of that refresh and it just gives me the values. So if you don't want the key, you don't care what the key is, it will give you values. 16. Multidimensional Arrays: Now. Why is this important? Because if I'm looping through an array that has another array in it called a multi dimensional ray, which yes, by the way, you can have a raise inside of raises like inception. With programming, you can loop through a list of people so we could say, Caleb, in fact, I'll show you real quick how this works, Caleb. And let's say one of my friend's name is Bob, and his website is facebook dot com. Oh, that Be cool. Wouldn't have being friends with a guy who made facebook dot com Zuckerberg. Okay, age. I know 35 he has zero cats. And now we can create another array. And this one is just called people, and this one has an array. The first value is Caleb, and the second value is friend mind blowing at this point. Now let's take a look at what this looks like. Print are people, and I'm gonna show you a quick way toe not execute any could blow this. You just write exit with semi colon and it's we'll execute all your code up until here. Up until here. And that's it. Yeah, can't really read that very well, your source. Look, our first type is array. That's people. That's what we printed. First value isn't array. The second value is also Marie Ray Array. We've got name and website age cats, all that good stuff in there. Now we can move through all these we can say for each friend as person and we can say Echo person. And then we know that we can get the name of each person. Make it smaller, so it fits on one line. Refreshments get. Get rid of this stuff because we don't need it. Refresh. Illegal offset. Name. So what is it looking for Here. OK, well, at this point in time, we've run into some sort of air, which is fantastic. This is actually a tremendous accidental mistake that I just made because it allows me to do this. Prints are. And now I can print our through each of these, get rid of that one. Because I don't need that either. And the mistake that I made was looping through each friend. What I actually want to do is live through each person, so I want to look through people as person, not friend, as person. There we go. That looks a lot healthier. Okay, so we vets to print statements in there. Let's go ahead current. That out a NCAA meant this one with that. Caleb, we've got Bob. And now you see the power behind Not only a raise, but for each loops. 17. Conditional IF Statements: Okay, let's talk about if statements if statements are what makes the programming world go round . We just learned about a raise and loops and all that stuff. Let's go ahead and create something that's a little more practical. So I'm gonna keep this example code in here, and I only want to ever, ever display anything that has to do with someone who's website is facebook dot com or whose age is, let's say, over 30. So in this for each loop, I can say if parentheses person age is greater than or equal to 30. And let's take a quick second to look at that arithmetic. So we know equal. That's one equal sign means you're assigning a value to a variable. We've seen that all the time, unless it's an associative array in this. In this case, then we call this a fat arrow, but we can see the regular equals sign up there. Next. We've got greater than then we've got less than then we've got greater than or equal to. We've got less than or equal to, and we've got does not equal. I'll demonstrate these in just a moment. So if the person's ages is 30 or higher Echo person name. And in here This will just say, Bub. Now, if we wanted an exact match, we would do this if his name rather his age is 35 display Bob displays Bob. And just so we can see that this is actually working, that this isn't like cashed or anything like that age is equal to refresh my page. Ages equal. Teoh Bob that's supposed to be named Whatever moving on. Ah, we also did. The is greater than so. If we do is greater than nothing will show up because is is data is 35 greater than not 25 is 35 greater than 35? No, it's not. 35 is the exact same as 35. In fact, there's another one called the strict operated, a strict comparison operator. And this one is saying it has to be the same data type We learned about data types. Caleb, why did we learn about those data types? Great question. Let's take a look right now. So we want to only get people who are, let's say, age 35. Cool. This is gonna work perfectly fine because this ages 35. You can see that it's in pink here. What if What if we said this has to be a string? The person's age has to be a string. Well, we know this one is an integer, but we know that this one is a string because of the quotations around it. It's refresher page, and it still works. And that is because PHP is loosely written. What that means is 35 in quotations is actually the same as 35 vote quotations. Just because it's so similar. PHP understand that these are the same Now There's a strict comparison, which is three equal signs, and this one will fail. Nothing will show up Bam just like that, as expected. And that's because this is looking for So these three here are looking for an exact match. It has to match the data type and has to match the value. So now if we change this one to have quotations around it, comment this out so my code doesn't error. Refresh. Voila, that works. But if I change this one back to an integer, it won't work. Look at that. So that strict comparison is is actually a good thing. So a lot of people say like Caleb, why? Why do we need to know about a loose comparison versus a strict comparison? While this one's technically faster, it doesn't have to do any sort of parsing. It doesn't have to try to figure out that there's the number 35 inside of a string, which could also contain a bunch of letters and characters and all sorts of stuff in there . All it has to do is say, Hey, look, I know that 35 is equal to 35 straightforward. All right, so this is and if so. 18. Else Statements: moment. What if the person's age is not 35? Let's say Echo your age is not 35. And let's put that person's name echo Person name. So what we're saying here is if that person's age is equal to strict operator 35 cool, say age is equal to And then I guess the person name. And you know, let's say that doesn't make it any sense that zari that's bothering me. Name is, uh, no, No. Nope, nope, nope. Built Ages 35 name is There we go. That makes a lot more sense now when I refresh the page is says your age is not 35. Caleb Colleen Ages 35 bub. In fact, let's after each one here. Let's do a little horizontal rules. So this breaks up nicely. It says your age is not 35 Caleb told me. Look at that. Killed Tony. Age 28. That's correct. And due to do ages 35 for well, in here it says, Bob, is that correct? That look, there it is. 35 35. Bob Wallach. Now you know about if else statements Now that is a very basic FL statement so we can compare any sort of data type in here 19. Comparison Operators: if we wanted to compare Ah Boolean we could say if something is equal to true There's also a shortcut way of doing us. We can say if something and this one assumes true. We can say if something does not equal true which is the same as saying Hold on to make more room down here so that you don't have to start the bottom of my screen if something does not equal true is the same thing is saying is something is equal to false. You can also do floats. So age is equal to 28.75 age doesn't exist. But if it did, age is equal to 28.75 That one works Cool. Cool. We could also right this one very loosely or we get right it not loosely and have an exact match. There's also a shortcut for the false bowling. If something is not true, I forgot this one and I'm just write this in here. Sorry If this one confuses you actually not Sorry. Kind of sort in Canadian. I apologize for everything. Something we know that this one is true. But what we can say is we put an exclamation mark at the beginning of it. This says not if something is not true. Execute some code inside of curly brackets again. More, more syntax year. Curly brackets are part of your syntax. The prince sees part of syntax dollar sign party your syntax. There you go. You learning all sorts of things. 20. Switch Statements: moving on right now. We're going to learn about something else called a switch statement. So a switch statement is like, Ah, and if else statement. But it's really, really fast. And by fast, I mean, it looks crazy, but it's technically less typing. So I'm gonna write. Name is equal to Caleb and switch name? Nope. That was by Thon, this one is PHP. And in here I type case Caleb Echo. Hey, you know, let's spell it wrong, because I find it sort of ironic Break. I will explain all of this in just a sec. Zephyr Echo. You're a cat Break. Default Echo. Nothing in here. Break. Okay, so this syntax looks crazy. We've got switch. What are we switching in here? This is basically saying if else and this is going to be like, if it's something else but something else, is it something else? And we can write as many of these as we want. So this one is saying, if my name is Caleb and a refresh the page, this will say, Hey, Caleb's felt wrong. Because the irony not really. If the name is effort will say you're a cat. If it's anything else. It'll just say nothing in here. So I'll refresh in. This one will say, Hey, Caleb. And if I change us to Zephyr, this one, I'll say you're a cat. And if I change this to anything else, anything else, this one will say nothing in here. Now what? This in Texas doing his thing? If the name is able to kill this is sort of the same as saying as if name is equal to Caleb . And this one is similar to saying If name is equal to Zephyr and this one is the equivalent of saying else now to end these, you always need to add that breaks a man because if you don't add that break statement, it will just flow into the next case. So if I change us back to, let's say Zephyr properly spelt though, ferial cool. That says your cat. But if I got rid of the break in here, just comment that out. So the code effectively is not there. There is no break statement. Well, still says your cat, we know that because PHP works from top to bottom. Now, if I got rid of this break statement, I'll just reintroduce this one because it doesn't need to be commented out. There is no break statement ends effort. So what this is saying is if it Zephyr or anything else, there we go. Now that's sort of a bad example. Let's take a look at a better example, and I will clean this up as to hopefully confuse you less. Save, Refresh. Hey, Caleb, give it to the brake says Hey, Caleb, your cat. I could also just do this. So it's a saying. If the name is Caleb or the name is Zephyr, it'll say you're a cat Azzam a cat. So I'm sort of same thing. That is the very quick crash course on switch statements. Sort of unique. Teoh PHP is in a lot of other languages, but there are several ways of doing these in languages that don't have switch statements. Okay, moving on 21. Functions: Let's take a look at functions. Functions are crazy. If you are brand new to programming, this might hurt your head a little bit. And you're probably gonna be like, uh what? But let me tell you functions are beautiful because they allow you to write one piece of code and you don't have to write it over and over and over again. For example, if I said name is equal to ah, Caleb and sentence is equal to my name is and I just put the variable in there echo sentence. It says My name is Caleb straightforward. We know all about this already. But what if I also wanted to do the same thing with another person, right. I could say name is equal to Nathan. It says, my name is Caleb. My name is Nathan. And just just for experimenting sake, let's take out this sentence. So we didn't override the original sentence. It's still thinks that this one has Caleb in there, but we've over written than the variable that should be in there. Let's save, refresh. Oh, would you look at that? It's It saved the reference to this one. So we actually need this sentence in here. The sentence variable. Now, what if I wanted to do this again? What if I wanted to write? Hi, my name is Zephyr. Or what? If I wanted to write, I got another cat. His name is Henry. Okay, so I just had a copy and paste that that was not the most painful thing in the world. But what if I wanted to do some some calculating What if I wanted to get somebody's chest score? What if I wanted to give someone a ul or what? I've wanted to plug in a u L. And it sends off for some data from Facebook or Google or some sort of a P I I don't wanna have to write that over and over and over again. So what I can do is throw it in this thing called a function and a function takes these things called parameters or arguments, and this parameter essentially allows you to customize everything. So what I'm gonna do here is I'm gonna type exit so that none of my code down here runs Well, uh, I'm gonna write a little function in here called Welcome. And I'm gonna throw in just a name and it will always say my name. Oh, no, not my name. Because I'm doing a welcome hello name and let's put a line break in there Just for good measure, save and refresh. Nothing happens because all I did, just like a constant dressed like an array or variable. All we did was define it. Well, we have to do now is we actually have to run this. So we run this by typing welcome. And this is looking for one parameter. So this parameter the 1st 1 in here is gonna be Caleb. I refresh the page. Hello, Caleb and I can change us to anything. Refresh change adds to Nathan spelt wrong. Nothing. And all it's doing is running this code. Now I can run this over and over and over again with different names in here. Caleb, I often get called. Not Jacob. Jacob. I also get called Calub sometimes. Yeah, funny enough, I get called Kellogg. Cool. Hello, Nathan. Caleb, Jacob. Caleb Kellogg. Awesome. So all I did was write three lines of code, and instead of having to copy all of this stuff, I just wrote this over and over again. awesome. Now what if I wanted to put this into a loop? I could do that as well. I could say four. I is equal to zero. I is less than five. I plus plus. Welcome name here. Let's get rid of the used It did it. Ah! Oh, hello. Now we're getting really fancy because I've written six lines of code that produce five lines in here. But if I wanted to, I could make this a lot longer. I could make us 50 and without writing 50 lines of code. Look at that. We have tons of stuff in here. Cool. So now that's the power behind a function and a loop. Now let's learn more about functions. How How can we customize this a little bit more? Let's say welcome. Does not take a name and we type. Welcome. Well, we know that welcomes going to echo something, but this should say hello. We're very familiar with us already. Variable is undefined name. This doesn't exist. What if we put name up here? Okay. If you come from a javascript background, this is called a closure where you've got a variable outside of a function. But it's accessible inside of the function. It does not exist in PHP. Don't try this, so let's go ahead and move that back down. We can throw that in here, and this is totally fine. That works, but that's where it defeats the point of the flexibility behind a function. So let's change that Back to name we'll put. I will put my favorite cat's name in their Zephyr hellos ever. We can also set a default value. So if there is nothing in there, we could say the default value is Caleb and Apologies. I was making a little smaller, so you can see this all on one line. Now the still says is effort because I gave it a name. But if I get rid of this, there's the default value that automatically kicks in. If there's nothing in there now, we can have multiple parameters in here. And let's move this on to multiple lines so that you can see that PHP is great with all sorts of white space name. Let's say age is equal to 28. That's the default age, and ah, my favorite sport is snowboarding. So now we have three parameters in here two of these air not being used. So So let's use these. Hello, Caleb. Your age is age, and you like sport. All right, refresh my page. It says, Hello, Caleb. You're a just 28. And you like snowboarding. What I can do in here is I can also se Nathan and his age is going to be 24. Will make him young younger than me anyways. Ah, and his favorite sport is going to be, um I don't know VR sports, I guess. E sport of some sort. And now all of a sudden it says, Hello, Nathan. Your age is 24 you like VR suite. So we over written all of these values. But if we don't give it any of these Oh, by the way, did something different here. I also named these. So this is pretty cool. So I can also do Age is equal to 24. And let's let's move this So that first parameter doesn't match a first parameter is name, age and sport. 123 This one's going to be age name. And then sport name is equal to Nathan. Oh, hello. The named variables didn't work because it's what it's trying to do here, even though we did name it. And this is really just for verbosity. If that's a word for to be more of her boasts, what it's trying to do is it's trying to pay this up. I'll put this on one line so we can see this again. Eso What this is trying to do is that first parameter always has to be. The name doesn't matter if you name it in here. Name or not, that 1st 1 always has to be named. And that sort of messes people up a little bit, especially come from a background like python Dario. That's all fixed now. We could also get rid of these. They're not actually necessary. It's just again to be more for both so that we know what we're referencing. Doesn't change anything if we get rid of it now. Cool. But what if we want to store this in a variable? Let's say we want to call this one sentence and we want to echo this later. So we say echo before echo after and in the middle. We have our sentence echo sentence. That is not how you spell sentence Echo sentence. Okay, so we have our sentence in here, and we've got before after now what this is doing and this one throws people off quite a bit, is this is running this function right now, And as as it is being called, it is also being echoed at the same time. So what we want to do is we want to do this thing called returning. So if we switch out echo for the word return, what this is doing is returning a value and it can only ever be one value. So it could be an array can be an object. It could be an integer string and be anything like that. But it's going to return this. And what this means is essentially, you can think of it like this. This welcome function is now replaced with whatever is going to be returned in here. But that functions also going to do all sorts of number crunching or it's gonna place your variables in a sentence like this. So now if I save this, you can see that before happens here. Hello, Nathan. You're just 24. You like VR and after So now it's in the proper spot now. Functions are so important that I'm going to spend a little bit of extra time in this crash course, and I am going to drive this nail home. I'm really gonna hammer this into your noggin. Okay? We're gonna create a new function keyword function, and we're going to do We're going to call it ad number one, number two and all this is going to dio because it's nice and easy to read. It's going to go Number one plus number two. Basic arithmetic here. So math number sign. If we wanted to subtract, it's subtract if we wanted to divide, divide multiplies an asterisk. Basic math. So what this is going to do is at number one and two together, and we can say total is equal to add 10 plus some crazy number. You know what? Let's make this a crazy number that I cannot add in in the top of my head off the top of my head. I mean, so this is gonna add this crazy number, whatever that is. And let's echo the total bam! It did that math for us. How can we tell it to the math. Well, we can either change numbers or we can look at the values. Let's do this. Let's do 10 and 15. This will be 25 boom, while I 25 just like that. Now, this is an oversimplification, because in all honesty, you wouldn't write a function just for this. What you would write is numb one plus thumb, too. And you would probably just have those numbers because you're throwing them into ah function. Anyways, you have access to those now. This is not a great example, but it is a nice simple example to really drive this point home. What happens if we echo this? I could get rid of the echo statement still shows up like if I echo still shows up once. And if I do a return statement with no echo, Well, uh, prints are total because that's just a number. That's all that is. And there you go. So that's that's really just the functions. Uh, my advice don't echo things in a function. It messes things up. Just return everything. It doesn't again. Doesn't have to be a number. It could be a string. It could be Ah, float or Boolean It could be really anything you want. But remember, return only works once. Oh, and one more thing. One more thing. Ah, for return. We could say, you know, I must not be like Don't tape it again, Echo more stuff here. What we're going to see here is that nothing now what we're going to see here is that this total is going to display whatever number one point number two is. But it's not going to display anything here because return what this does is it says anything below this. It doesn't matter. It doesn't care about what that is. When I refresh the page, it just says 25 in here. Now, if I move this up a line, that's a different story. But if I move it down a line and refresh Walla, there we go. So once you use this return, keyword everything below. It does not matter. That's important to remember, because sometimes you'll see someone say like If you know what, let's let's make this more complicated. Total is equal to numb one plus numb to, if total is greater than 50 return two large else, which we actually don't need to run because if there is like if this doesn't run, it's just going to run the other code anyways. So let's do this. Ah, return. Nice number total. Okay, says Nice number 25. But if I make this number like 45 plus 10 or templates 45 it says two large because that number is over 50. But what it says here is too large. And it didn't it didn't execute any of this stuff. Watch us Echo. Nothing happens here. Hold on. Nothing happens here. There we go. Refresh My page still says to large echo, Nothing happens here. Does not execute because guess what this return statement is saying? Effectively dysfunction is done. Free up resources. Go back to the top of the function, find the end of the function and then just keep running your code. That's all it's doing. OK, there you go. That's functions. I've really driven the nail home. It's a weird thing to get a hold of in your head to sort of figure out, but when to get them all. Man, they're beautiful 22. Super Global Variables: All right, moving on. Let's clean this up and I'm going to tell you something. I think it's fantastic. It's called a super global variable. Now, there are a few different kinds of these. Ah, the 1st 1 we're gonna talk about is called the Get variable. And you see this a lot in euros. And and now that you're aware of these, you're going to see them all the time. So it starts with a question mark, and then you've got Ah, let's see, this name is equal to Caleb Tallinn. Okay? Nothing happens. Maybe cause I spent name wrong. No, just kidding. Nothing happens because I got nothing in my code. Now this name this is called a super global variable, and it's accessible with gets and it looks like an array name. So what we can do here is name is equal to echo name, or I mean, we could even do the shortcut. We just echo, get name, get rid of that. And if we wanted to add more of these, we can add the M percent, the and symbol in here. And age is equal to 28. And CASS is equal to two. So you see these all the time You see on Facebook, you see, don't Google. You see it on every single surface. And this is one way of passing variables from your all to you. Well, so we can say name Echo is get age years old. I'm only by the way, I'm only putting these on separate lines so that you can read this little easier. Typically, my editors a lot smaller and I would throw it all into one line, Um, or just make it a lot cleaner on one or two lines. But for the sake of simplicity and reading, it goes on multiple lines. And this is totally okay, So this is going to say name is eight years old, need a space in there and has get New York get cats. Tutta Caleb told me 28 years old and has two cats. What if I said 200 cats? What if I said hell of Tallinn is 10 years old? A little pre few peasant boy who has 200 cats? This is all changing through the u. R. L. Now we can accept different parameters. This is what makes this language very dynamic. This is one of the reasons that PHP is so fantastic. There's another one called Post. So added, uh, if I did this underscore Post, nothing happens because it says index name is not defined. What this is saying is, Post Index does not exist. What happens if we did print are get I'll just exit from here just, uh, hired my code for a little bit. Refresh my page. There's nothing in there. But if I did name is equal to test. Oh, hello If I did Ah, and percent and is equal to Sorry and percent age is equal to 123. You see how this is growing and percent? Uh, what? I have a nickname or a user name? A nickname is equal to Caleb. Look at that. Chrome also decided to automatically escape my apostrophes, so we'll just put killed. Sweet. So that is the get super global variable 23. Forms: Okay, let's let's throw this into a form in PHP. And really any service I'd language. One of the key components is a form now forms refresh. My page forms are very, very important. Ah, form has a method. You've probably learned about this in in HTML. Maybe a little bit in JavaScript, but four has a method. That method is either get or post. I mean, it could actually be a bunch of other things, but we're gonna stick with a two basic. So this one is Get we're gonna put a label in here four name and the input is going to be type is text and this one has a name of name. So pay close attention to this this attribute here called Name and let's put another label in here. We'll call this one age. Do I make so many typos today? It is becoming unbearable for me. This one is a number. Name is equal to age. And let's put a submit button in here. Button type is equal to submit. It's ah, mitt. Okay, this is gonna be an ugly form, But bear with me. Sorry, I can't do that. That is that is just far too hard to read scenario. Okay, so we've got name, age and submit button. My name is gonna be Caleb. My age. You? No, no, no, no. I got ahead of myself with Refresher page Brand new start. My name is Caleb. My age is 28. I hit. Submit. Oh, hello. Those air now in my you, Earl. That's what get means. Get me. Is that these are going to be in your you, Earl. And now we can say if is set. Get. I know we'll just call it name. This is not great validation, by the way. But this is a form of validation. Echo yet name is get age years old. And now we're mixing html in PHP. Oh, hello. Caleb is 28 years old. What if I said Zephyr? My buddy Zephyr? I apologize. My fingers are not cooperating today at all. As I make 30,000 typos in a row. His efforts to look at that So it refresh the page. My, your I'll change. It says Zephyr is two years old. I am just like that. So that is a get form now. A post form is little bit different. 24. POST Forms: a post form does not show up in the U L at all. So I'm gonna get rid of this stuff so that we know that no more get is going to operate. And when I submit, nothing happens. But when I try to refresh the page, hold on. Let me put it a been here. Try to refresh the page. Nothing happens. So let's go ahead and swap out. Underscore, Get for underscore Post again. This is called a super global variable, and this one does not show up in my girl at all. So this one is going to say, Caleb, my age is 90. Some days I feel like I'm 90. Is this Caleb is 90 years old, but if you notice in my URL there, there's nothing in there. It's a little bit more secure says a better way to, for example, create a log. Inform where someone has to submit their password. Never put a password in the U Earl. That's unsecure. Everyone can see that you want to hide that password, and that's what Post does. Now, if you're not sure if a request is post or get, you can also do underscore request it will do the same thing. Ah, that the data it's do Calub is 12 years old. Same thing. Request works. Ah, we can also change us to get and let's refresh this page and we'll put any name in your any name. Is any age really old? Apparently, any name is 123,123 years old. And that request is basically the lazy way of getting either get or a post parameter, not a parameter super global variable. And you can directly put those into a function as well. We were talking about functions. Uh, we do something that goes function. Name, Echo. Hello, Echo three. Quit name and let's just do function. Name. Let's get rid of this junk. Refresh my page. Hello. Any name? Because that's in my UL. But if I get rid of this okay and to find index request name does not exist. If I changes to a post, refresh my page. It's still going to complain because there is no index name. And let's put any name in here as as is the name. It says hello as as, and that's because we didn't have to pass it through a name parameter like we did before. It just it works because it's a super global variable. It is allowed to break the scope of functions and all sorts of things breaks a bunch of rules. Basically, it's fantastic. Now I would recommend Don't use request because that's lazy. You should always know if a form of submitting, using, get or if a form is submitting using post. 25. Summary: already. There you go. That is the PHP crash course. You've learned all sorts of things, but just to recap, you've learned what PHP is you've learned who uses PHP. You've learned how to install Zampa, which is a big deal for a lot of people. You've learned that in fact, PHP is not dying. You see this question all the time. It drives me nuts. Feature is actually growing. It's getting more popular. I've learned about PHP syntax. You learn about variables, echo print. Um, prints are comments like single double in multi line comments. You've learned single and double quotes. You've learned about data types like Array in Float String Bull. You've learned that you've learnt that 13 is not the same as 13 with quotations around it. Ah, you've learned about strings, constants again, a raise You've learned about four loops while loops for each loops. If else statements switch statements, you learned some basic math, some basic arithmetic. You learned to vote functions that is a big one for a lot of people. You've learned what super global variables, and you learned how to submit forms in order to take user input. Okay, we are done with all of that said thank you for tuning into my PHP crash course. I hope to see you in one of my other courses. If you thought that this PHP crash course was really useful, albeit I know it was very fast paced, but if you thought this was very, very useful to you, please, by all means, share it with your friends. Shared encoding groups shared amongst the world. This this is probably the fastest way to learn. PHP is through this. This is a zero fluff, no magic, no nonsense crash course on PHP, and you got all the way through it. So congratulations and congratulations on dealing with all of my typos. Because I know I was getting frustrated already with all that said, I'm not gonna drag this out any longer. Thank you for tuning in. I appreciate your attention. And I hope this has really helped you