PHP For Everybody - The perfect PHP beginners course! | Kalob Taulien | Skillshare

PHP For Everybody - The perfect PHP beginners course!

Kalob Taulien, Web Development Teacher

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
49 Lessons (5h 41m)
    • 1. PHP For Everybody

      3:37
    • 2. How PHP Works

      4:20
    • 3. What You Should Know First

      2:14
    • 4. Installing PHP 7

      4:43
    • 5. (Optional) Installing XAMPP

      3:04
    • 6. What Is A PHP File?

      6:27
    • 7. Who Uses PHP?

      5:14
    • 8. What's The Difference Between Frontend and Backend Coding?

      3:28
    • 9. Don't Forget To Rate This Course, Please.

      0:33
    • 10. Tools You'll Need

      5:32
    • 11. Documentation

      6:53
    • 12. PHP Syntax

      7:05
    • 13. Echo/Print

      5:41
    • 14. Code Commenting

      5:51
    • 15. Variables

      8:22
    • 16. Data Types

      9:08
    • 17. Mixing PHP and HTML

      5:21
    • 18. Unsetting Variables

      3:14
    • 19. Debugging Variables

      6:29
    • 20. Better Debugging

      5:12
    • 21. Type Casting

      9:51
    • 22. Arithmetic (Math)

      7:28
    • 23. Constants

      4:09
    • 24. Concatenation

      5:22
    • 25. Quotes vs. Apostrophes

      6:02
    • 26. String Replacement

      6:10
    • 27. Arrays

      16:18
    • 28. Sorting Arrays

      7:04
    • 29. Conditional Statements

      13:00
    • 30. Else Statements

      4:33
    • 31. Else If Statements

      8:04
    • 32. Comparison Operators

      13:27
    • 33. Incremental and Decremental Operators

      3:46
    • 34. Not True

      9:14
    • 35. Ternary Logic

      10:42
    • 36. Implode / Explode

      8:36
    • 37. Switch Statements

      13:22
    • 38. While Loops

      9:45
    • 39. For Loops

      6:16
    • 40. Foreach Loops

      17:15
    • 41. Check If Variable Is Set

      7:36
    • 42. Is_* Functions

      7:36
    • 43. Checking If Variable Is Empty

      3:52
    • 44. Starting With Web Form Data

      2:49
    • 45. GET Requests

      6:19
    • 46. POST Requests

      10:10
    • 47. Required Form Fields

      10:05
    • 48. Final Project

      4:21
    • 49. Course Summary

      5:33

About This Class

Learn how to start coding websites using PHP, one of the internets most famous and most used programming languages! 

This course is designed to take you from zero to hero and by the end of the course you will be able to freelance, code custom WordPress, and start learning Laravel/Symfony. This course was also designed to teach you programming fundamentals. So while you're learning, you'll also be learning how to code works behind the scenes, and that will enable you to jump to other programming languages very quickly (such as Python, Java, JavaScript, C, Swift, Kotlin, etc).

fd757e04

Transcripts

1. PHP For Everybody: Hello and welcome to PHP for everybody. My name is Caleb telling, and I've taught over 130,000 students worldwide, and I have started several start ups by writing PHP. Now PHP is a super in demand language. It is very hot right now. There are over 1.8 billion websites in the world, and over one in three of them are using PHP. So roughly 600 million websites are using PHP. By the end of this course, you will be able to talk very confidently about programming, programming, fundamentals and even server side coding, and you can also consider yourself a junior PHP developer. In this course, you will learn programming fundamentals from scratch, and each lesson comes with a task at the end of it. Or, as I call it, homework for some immediate hands on practice and experience with everything you've just learned. Some things you will learn in this course are what is PHP? Where is PHP used? We'll talk about variables, data types, data structures, conditional statements. We will talk about four loops while loops form validation forms and so much more. At the end of this course, there's a project where you could get hands on experience with everything you have learned in this course. And if you are brand new to Web development or or you're interested in just learning PHP, then this course is definitely for you. However, if you already know Ph. B, if you are familiar with it a little bit ah, you would consider yourself an intermediate or expert PHP developer. This course is not for you. Don't forget to check out some of the free preview lessons down below. And if you like what you see in role now and I'll see you inside Hello and welcome to PHP for everybody. I'm Caleb telling, and I've taught over 130,000 students worldwide, and I've built several start ups using just PHP. PHP is a hot language. It is in serious demand right now and over one in three websites are using PHP, so it makes sense to learn it right now. By the end of this course, you will be able to talk confidently about what PHP is. Programming, programming, fundamentals, server side coding, and you can actually consider yourself to be a junior PHP developer in this course You will also learn programming fundamentals from scratch, so no experience is necessary. And every video lesson comes with a task at the end of it, so you can get some hands on experience right away. Now some of the things that you will learn in this course are what is PHP? Where's PHP? Used variables, data types, data structures, four loops, conditional statements, wild loops, forms form validation, how to customize a website based on user input and so much more. At the end of this course is a project where you can get practice and experience bundling all of your skills together. Everything you've learned in this course is going to come together under one project. Now, if you are brand new to Web development or you're just interested in learning PHP, this course is absolutely for you. However, if you are already familiar with PHP, if you would consider yourself to be an intermediate or an expert PHP developer, this course is not for you. Now, don't forget to check out some of the free preview lessons down. Be low. And if you like what you see in real now and I will see you on the inside 2. How PHP Works: all right, before we actually start learning about what PHP is works, know the intricacies behind it. Let's take a look at what it does. So I'm just gonna quickly skip through a bunch of stuff here. We're going to learn about all the bits and pieces, throat the course, and actually, in the next several lessons, we're going to actually get her hands very charity with writing some actual code, which is great for hands on experience. But for now, I just want to show you how this works. So here's an example of how PHP works. I guess so. On my left I have my text editor. I'm just using sublime. You can use Adam V s code. Really? Any other text editor you like? I just like sublime. On the right is Google Chrome. It's just a Web browser. It's loaded up with local host 8000 lessons. We'll talk about you, r l structure and what the 8000 means and all that stuff in just a little bit. But for now, let's go ahead and create our first string. So, actually, before I do anything, I'm gonna refresh this page and you'll see that nothing shows up, there is just a blank page. And in fact, if I view the source, there's absolutely nothing there. Now if I go into sublime and I type hello world and I say this go over to chrome and to give it a refresh boom and says Hello, world. Now, if you're familiar with HTML, this is not a mind blowing thing. This is not anything new. The only difference is it looks like you're writing a lot more code than what you would normally right When you're writing html And if I go into the source here, refresh. You can see that in the source. It also says hello, world. Now where this gets really, really powerful is the dynamic nature of what PHP is. So if I type in here Ah, let's type in color is equal to blue and I hit enter Absolutely nothing is gonna change literally Nothing is gonna change. But if I write regular html in here and I say the body html and maybe also all paragraphs just reading some general CSS here they all have to have a background color of I'm gonna make this little smaller so you can see it all in one line, they only to have a background color off whatever this new color is. So again, don't worry about what this really is on. We're gonna get into all of the intricacies in this course just as a reminder. I'm just showing you how this works. So I'm gonna show you that we can get the color from the Earl by typing get color. And when I saved the page and refresh this my pages blue And if I change the you on I see red Or if I wanted to change it and go to Black right? This is the dynamic nature of what PHP does for you. It changes your templates. You don't need to compile anything. This doesn't like sea or python or anything like that. It just works. And it's a very quick So this is a very basic example of what PHP is on a dynamic level. Now if I changes back to white, everything looks white. And if we go into the source code and give that a refresh, we can actually see that Hello World shows up and we can see that right there. We've got the style and we're saying body HTML and P tags all have to have a background color off. This one doesn't have anything. So that's type question mark is equal to blue and it puts blue in there for us or again, If I changed it to read, it changes it to read. And now this is writing CSS for us. Now, we don't generally use PHP to write CSS, but we do right PHP to change our html to change the output. So if the color is red, can we show certain information If the user is locked in, do we show them their own account information so you can see how that's already relatable? So that is how PHP works on a very basic level. Now we're going to get into what all of us actually is. How it operates, how it prints to the page functions, objects, you name it, we're going to get into it. But for now, again, I just wanted to show you like, hey, this is what it can do. And this only took me like in total. If I wasn't, you know, creating this list lesson for you. This probably would have only taken me 15 seconds, and I could have changed the background color of any page just like that. All right, so that's a basic example. If you want to give that a shot. Ah, if you don't know how to get set up with PHP or anything like that Ah, the next few lessons are definitely gonna help you up, and I'll see you over there. 3. What You Should Know First: Okay, welcome to another lesson. I guess this one is not really a lesson more than it's just I'm letting you know some of the prerequisites that you should ideally have before learning PHP. Now, the honest truth is you don't need to know a whole lot before you learn PHP. Now the reason that I say this is because although it's great to know your HTML as well as your CSS, you don't actually need those because PHP is a server side language, meaning it runs on the server. It has nothing to do with your browser except for the fact that if your PHP spits out a little bit of hte email or CSS or some JavaScript or something, your browser will render that as if you wrote it in HTML CSS or JavaScript. So that's cool. I would suggest that you do know some HTML and CSS. If you don't know HTML or CSS. I have lessons on both of those subjects. If you're if you're sort of a keener and you want to know a little bit more, you can also learn JavaScript. I've got a great JavaScript essentials. Course it's highly rated. Definitely go check those out. But for now, I'm gonna let you know that technically those air unnecessary. You do not need to know HTML or CSS or JavaScript or python or anything. This course will take you from zero to hero. From a dizzy, you will know exactly what you have to do. By the end of this course, you will know everything. There is no a boat PHP and you will be a professional PHP developer. By the end of this course again, you do not need to know html CSS. But in this course, you will definitely see me, right? Html CSS Probably some JavaScript here and there. Anything that's not PHP related. Guess what? You don't have to learn it again. I would suggest that you do learn it. But if you see me writing any of this, don't freak out. It's not necessary. This course is strictly PHP. Everything else is extra. I want you to focus on just the PHP stuff now. Right now, you might not know what that PHP code looks like. And in a little bit we're going to get into PHP syntax, variables, how things are written, how to make your code work what happens when code breaks all that good stuff. So again, if you don't know your HTML aeration of five CSS CSS three JavaScript, all that stuff, don't worry about it. It's not technically necessary. But if you see me writing it again, don't freak out. It's just some icing on the cake for this course. 4. Installing PHP 7: Okay. How low in this lesson, we need to learn how to install PHP. Now there's good news and there's bad news depending on which operating system you're using . If you're using a Mac like a Mac book, which I'm currently using, by the way it does not matter what operating system you're using. You do not need to buy a Mac. I get this question all the time. You do not need Lennix. You do not need windows. You just need a operating system. So whether you're using Windows, Mac or Linux is totally fine. There are options for you, but you need to install them. So what I was saying before was, when you buy a Mac book, PHP already comes on your computer. You might need to update. It might come with PHP 5.6, and in this course we're using PHP 5.6 is wrong. We're using PHP 7.0, although technically we are on PHP 7.2 right now. But I'm just in a use PHP seven just for the simplicity of it. Now, if PHP doesn't come on your computer or even if it does, you might want an easier way to manage your sites. It's not like reading an HTML CSS and JavaScript file, where you can just write thes these blobs of code and they just work. You actually need a server to run PHP now. To do that, we can head over to Apache friends dot or GTA slash download dot html, and it will give us options we can download. Zap. I actually spelt that wrong. We can down the exempt for windows for Lennox Ah, for Mac. Now, I am not going to use any of these. I'm going to be used something called Docker. Now, if you really want to increase your PHP game, I would suggest using Docker, and I will provide the link to my doctor set up for this course so that you can use everything that I'm using in one of my get hub repose. And ah, it's not currently up as I'm recording this, but I will go and make that repo in just a matter of moments right after this video and it will be called PHP Doctor or something to that effect so you can go to get hub dot com slash Caleb tolling slash PHP dash doctor, and you will be able to get the doctor files, make files. Dr. Compose All that stuff that I'm using, I'll build a little. Read me in there. All right? A little read me in there on how to install it, if that is too much for you, and it's totally okay. If that is too much for you, then don't use Docker. I like Dr because basically, you can set up a small virtual operating system inside of your operating system and everything is completely contained. So nothing's going to leak into your actual system. So you're not bloating your operating system Now again, if that is too much for you, don't worry about it. Download Samp from Apache friends dot org's slash download dot html Again, whether you're on Windows, Linux or year on a Mac. That's cool. Download it, install it, get it running. It should be very, very easy. The version that you're gonna want is either version 77.1 or 7.2. Get the most recent one if you can get 7.2 or 7.3 is out, which it currently is not. But if while you're watching a 7.3 is owed. Maybe get that one instead. It's always best to stay up to date with these things. I'm just recording Petri 7.0 for the sake of being a little more backwards compatible for people who might not have access to 7.1 or 7.2. So your task for this lesson is to head on over to Apache friends at orig. Download Samp. Um, if you're on Windows, there's another option called Wamp. It's basically the exact same thing for Windows, But if Sam I supported here, why not get it here and again, if you're feeling a little more confident and you don't want to use something as easy as amping, you want to get a little more into develops down the road. If you're already familiar with some of that stuff and you might not be in again if you're not familiar with that, it's OK. Don't feel overwhelmed. There's a lot of stuff you're going to learn in this course, but if you wanted to increase your game a bit, you can download Docker and Docker compose again. It will be in the Read me file in my get hub repository. And then you can install all of this via Docker. Otherwise, really, all you need to do is get some sort of server set up. Zampa, Wamp, Doctor, whatever. It just needs to run your pH. Me? I don't I don't even care if you get from Apache friends are or have no association with them. You can get it from literally anywhere. If you want to install it right on your operating system and do it all manually. By all means. Go for it. I just need you to be able to run PHP files on your local computer. Probably your laptop. Cool. So once you have all that set up and good to go head on over to the next video and we will learn about what a PHP file actually is and how to execute it. 5. (Optional) Installing XAMPP: 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 clinic seeking down the clinics version as well eso I'm going down with 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 today. 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 exempt dot A PP. If you're on windows, you just need to install the e x e file. Yeah, I'm going to 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 Zab. 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 forward it there. 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 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 for function, and it 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. 6. What Is A PHP File?: Okay, by now, you should have realized that when I type something into the URL here for a PHP file, it goes index dot PHP. Now what? Actually is that so you have an index file here? Let's make this little bigger so you can see it's easier. We have index dot PHP. What index means is when there are no other files or even if there are other files, your browser is always going to try to figure out what the 1st 1 it should load. So if if you have index dot PHP and home dot PHP and home page dot PHP, Which one should be loaded first when there is no index dot PHP file. Now, bear with me because this will make sense in just a moment. You notice I've changed the URL here. There's nothing there now. What this means is because there's nothing there. My my server, that's running PHP is going to say the 1st 1 I'm looking for is index dot PHP. Does this file exist? If it does, it will show it. And this file, as you can see right up here, is called index dot PHP and it shows up in here as we would expect. Now I'll save this and refresh just so you can see that I'm not lying. Look, my text showed up just as we thought it would. Now, what do you need to actually serve a PHP file? Well, as you can see, I have no Ph b in this file at all. In fact, it's peer html. And when I go and view the source, we can see that these are the exact same thing here. I make this bigger so you can see this as well. And so this says each one What is a dot PHP file? And in my sublime editor, it says the exact same thing. Now, could I have named this index dot html? Could I have named this index dot CSS? Yes, absolutely. I could have. And what, it that have changed anything at this point? No, because we're not running any PHP. Now, let's take a look at an example here. Let's type a little bit of PHP now. You don't need to understand what this PHP is yet. I'm just showing you that dot PHP in the file name extension is actually really important, so I type echo test. And when I refresh the page, it says test perfect. But if I duplicate this page jazz bear with me as I duplicate this page and I'm gonna call this one dot html so you can see that my syntax highlighting is has already changed. That's because I'm using a plug in in sublime. Now, if I go to it slash index dot html nothing shows up here, So I've got this whole PHP echo test. Nothing is showing up now. If I go in view this source, it will show up. Watch this. Look, there it is. Now, why does it not show up on the front page? Why does test not show up here but showed up in the index dot PHP file And again, I'll just show you as a demonstration that boom There it is. It's says test. And when I go to html file, it doesn't say anything, but in the source, it's there. Now. The reason for this is because your browser is looking for these opening and closing brackets these greater than less than symbols. It's trying to interpret that this is HTML, but it doesn't understand what it is so it's not showing it, but it's still in the source. Okay, so jumping back to the index dot PHP farms and close these down real quick and go back to the PHP file. Boom. There it is. Now, our server. Ah, whether you run example map, doctor, whatever. Whatever is running PHP on your computer right now is looking for that dot PHP file extension. Without it, it doesn't run. It just renders as regular HTML. Now, when we look at the source of this PHP file, we don't see this PHP echo this closing syntax again. Don't worry about what that is. We don't see any of that. All we see is test. Now, this is part of the power behind PHP. When you write Ph. B inside of an HTML file, recall this a template. It doesn't show your PHP code at all. In fact, it's only going to show what it's supposed to show. And that hides what's called your source code so people can't just open up your website and steal your code because they don't know what is running in here. They don't know if it's checking to see if someone is signed in or locked out. Or if they have a certain permission, or if they're allowed to do something or not allowed to do something or if they have a certain gender or if they're older than 18 or any sort of website verification. They don't know that in the code because your source code is hidden with this beautiful PHP tag. So essentially, this is what a PHP file is. Don't sweat it too much. You're going to get used to all of this again. If you're feeling a little overwhelmed, just bear with be once we actually start digging into this and starts typing our own html not html rather. I mean PHP. Sorry about that one. Once we start writing our own PHP, this is going to make a lot more sense to you, I promise. But for now, what you need to know is that every time you write a PHP file, it needs to end in dot PHP not dot txt not dot html not dot abc not 0.0.0.0.0.123 not dot CS s not dot Js every file and let me write this down. Every file must end in dot PHP. That extension is incredibly important. That's how Apache, which is like the middle man on your server. It's the one that reads the PHP files and says, Okay. Ah, I'm gonna read what this is. And I'm only going to actually help you display the word test so Apache and again we'll talk about Apache much, much, much down the road. You don't need to know too much about that. But Apache is the guy that says, Oh, your PHP file. Guess what? I know how to handle us. This is PHP. This is what I do. This is my thing. I'm only going to show you the PHP. I'm not gonna render this like HTML like you normally would. I'm gonna render this like PHP because that's what this file is. So that is the long winded explanation off what a PHP file essentially is. So just remember, if you're gonna takes one thing away from this lesson, that all your PHP files need to end in dot p h p 7. Who Uses PHP?: All right, let's take a look at who uses PHP. Now. When you look at different programming languages, there's Ruby. There's python there. See? Swift Scotland, Java PHP. You know you name it right. JavaScript is a huge one right now. And there are a lot of people in the world that say, Oh, you know, is PHP dying? I guess I'm not saying they're asking that Is PHP going to die? Is is it a dying language? And there are people who say Yes, but that's because they simply don't know better. PHP is by far the world's most popular server side programming language. Now there are people who will disagree with you, but these people do not understand facts. OK, let's take a look at some facts now. We did a quick Google on, uh, what did I type in here? I typed in, uh, who uses PHP, and I went to 1/4 answer and we have Facebook Wikipedia by do Yahoo. I mean, Yahoo is not really around anymore, cos sort of crumbled tumbler flicker WordPress, which is a huge one. This one runs over 27% off all the Web sites on the Internet. So basically one in four websites that you have visited are running on PHP. Actually, more than that, chances are you're using Facebook, or you might be using slack, which was built with PHP as well. Um, male chimp use it uses it. Ah, what's another big one here? Dig uses it, although dig is not as popular as it once was. But these are still huge, huge companies that are using PHP. Now the big one. I want to focus on his WordPress. WordPress uses PHP. It's strictly PHP Drew. Pill and Juma also use PHP, so let's make a little this year. So we've wordpress websites which make up 27% of all websites, and that number is only growing. That number used to be 22% than it was 23 it just kept going up and up and up droop. Oh, now I don't I don't actually know how many sites are running. Drew Paul. Um, that stat has not been published as far as I'm aware anyways, but there are a lot of dribble sites out there. Jumla. Okay. How many times a day do you go to Facebook? How many times a day, Do you? Slack? If you're in the tech industry, chances are you're using slack to communicate with your colleagues. Your co workers appears. If you have ever received a marketing email, chances are one of those emails, at least one of them, but probably like hundreds and hundreds of them have been from this company called Mail Chimp Mail. Chimp uses PHP. That's a huge one. Okay, Wikipedia. We have all used Wikipedia. Wikipedia uses PHP. It was built in a time when PHP was all the rage and guess, but it still works. It is one of the top websites in the entire world. Facebook is also one of the top websites in the entire world. Both of them are running PHP. So when someone says you who's using Ph, we really tell me who who's using this? You say the biggest, most common websites in the world are using PHP Now. That is not to say that other languages are bad. Great. There are sites that use python. There are sites that use Java, their sites that use node.js, which is server side javascript. There are sites that will use Ruby and an example of these Python, YouTube, Jabba Amazon. No Js Netflix, Ruby get hub. So is it safe to say that you should be learning PHP? I would say absolutely yes if you are not learning PHP. Honestly, I think that is a huge mistake. Based purely on the number 27 27% of all websites run on PHP. Now that's not using Facebook or slack or mail chimp or any sort of a P I or doing anything custom. That is purely based on the fact that more than one in four websites that you visit are using PHP. Now. If you want a job, you have to go where the demand is and you always want to be in demand. So when there are inevitably, 30% of all websites are using PHP, are there going to be more PHP jobs or they're going to be Mawr Python jobs? Economically speaking, there will always be more PHP jobs available for you just because the demand is higher, the use is higher. Will that change in the next 10 years? Maybe. Who knows? But it hasn't changed in the last 15 almost 20 years, and it's unlikely to change any time soon, so learning PHP is a really, really good idea and getting people involved to learn PHP is also good idea because you don't have to learn alone. You can also use our Facebook group called Learning to Code to ask for questions to, ah, look over to piers to see what they're building to get help from everybody, including myself. Ask questions, get involved. It makes learning anything a lot easier. So in summary, when someone asks you who uses PHP, you can say at least one of these guys. 8. What's The Difference Between Frontend and Backend Coding?: Okay. Another question that's going to come up a lot is what is front end and what is back end now. You may or may not be familiar with either of these terms. I'm just going to assume that you aren't familiar with these. If you are, feel free to skip this video and just head on over to the next one to begin. Let's talk about what front end work is. Assuming I could type anything correctly. Front End is purely HTML CSS and browser based JavaScript by browser based JavaScript. I mean, not know dot Js not expressed RGs. It's just like regular JavaScript es six stuff that you run on your browser that does not require a server. That is all. Front end is back. End is databases. It's often mostly Dev ups. It's writing PHP. Its databases. Like my SQL, it's file management. Back end could also include right writing languages like Python, ruby, Java, you name it. If it runs on a server, it is back in, So that is the difference. So a lot of people say Campbell, what is the real difference? Like, I mean, if I right some HTML and I write some python or I write some CSS and write some PHP and my both front and back end. Well, you know, you met you might be Now if you dio both front and back and that is called full stack. And what full stack means is you can do front end and back end. That does not necessarily mean that you can do everything in the back and world. Front end is very limited. Okay, So front. And really what? Ah, front and Effie. For short front end means is html html five CSS CSS three javascript, including things like Jake Weary React View. Yes. 678 You know, all that stuff that is purely front end. So if you know how to do html, CSS and javascript, you're a front end developer if you know how to do. Ah, some database work, some some PHP work, perhaps, or another language. It doesn't necessarily have to be PHP, but if you know how to do any of that back and stuff B e for short, then you're probably writing python PHP. You're probably working with something like Engine X or Apache. In this course, we're using Apache, um, and you're probably working with some sort of database. Now if you can mix and match these, so if you can do HTML CSS JavaScript and you can also do like python and post dress or PHP and my SQL or Apache and PHP with JavaScript and CSS, then you're a full stack developer. That's all that means. Full stack means you were both front and back end. Front line is html CSS JavaScript Back end is basically everything that is not front end, which is a huge, huge world, and that is the only difference. Really, it comes down to do you write code on a server or on ah browser, and I shouldn't be using the word on what I should be using is, do you write code for a server or for a browser? That's the difference 9. Don't Forget To Rate This Course, Please.: Hello, It's me. I'm the voice behind the videos. Just a quick reminder that if you've enjoyed any of these videos so far, you can follow me on skill share. But more importantly, you can actually rate this course. And just by simply reading this course, that actually helps me out a lot. It's super easy and super quick only takes a couple seconds, and I mean it really would mean the world to me. So if you've if you've loved what I've been teaching you, if you like the style of my courses, give that a good old thumbs up, Um, and let other people know what you fluffed about these videos as well. Cheers. 10. Tools You'll Need: Okay. As a Web developer, you need some tools like any trade, carpentry, machining, electrical. Those all have tools. Web development is no different. You have tools that you need. So one of my favorite tools is a text editor called Sublime, and you're going to need a text editor as well. Now there are many different editors out there. I like sublime. This is one of my favorite ones, but there's also Adam. There's also V s code. Ah, there's Dreamweaver. No pad plus plus. Generally, I tell people to stick with one of these three. They're sort of the big three right now. Sublime has been around probably the longest. I like it because it's lightweight. It's superfast. I can open big files with it and it doesn't have a problem crunching that kind of data. And V s code is the newest one made by Microsoft, and it's actually really, really good, too. So you're going to need a tax editor if you don't have one of those. Go and get one of those now. Ah, heads up. V s code is free, Adam. Ah, I believe is free. Actually, don't use Adam, so I couldn't tell you, um sublime is free to use, but it's called Nag where So every now and then has a little pop ups like Oh, hey, pay for me. I paid for my version of sublime. I think is worth it. If you don't want to pay for it, definitely check out V s code. The next to where you're going to need is something called Git. Now, in this course, I'm going to be using get a little bit here a little bit there. It's not really required, But as a Web developer, it is good practice. Put your code in a version repository where you can see your get history. You can collaborate with other people, all that good stuff. If you don't know what get is, maybe go and Google something along lines like, um, what is get. And if after reading an article or two, you still aren't sure what get is that's cool. I would suggest getting get downloaded through your command line. Ah, brew, install, get or sudo apt Get, uh, yeah, install Get something like that or it comes with um V s code has a plug in Forget it's a visual one sublime has one is also visual. I do the command line stuff. I'm gonna teach you the command line stuff again. That's completely optional. But you're going to need get anyways because eventually, as a developer, it's just a requirement. You need to be able to collaborate with other people on the same project with the same code at different points of time. And you need to be able to overlap. That coat somehow get, is the way we do that. Now you're going to want a get hub account, and you might also want a get lab account. So it's just type that out and get lab account and get hub account. Get help. Account is basically your public repository. So if you looked at my get hub account, I've got a few repositories on their free, useful things. I don't have really any projects on there, though, because a lot of my code needs to stay private and private repositories. A repository is basically a folder with all of your code inside of it stored with get hub. Ah, private repository is going to cost you money with get hub, but with get lab and let's just put that dot com in there with get lab, you get free repositories. Basically, the services are identical, but get lab gives you free repositories. Get hub does not beget. Hubby is sort of like you know, it's where your future employer is going to look at its going. They're going to say, Oh, do you have a get hub account? You should be able to say yes and you're also going to need some sort of server on your computer. It doesn't have to be a cloud server. Doesn't have to be a real server, but it has to act as a server Now. We've already talked about Zampa and I must write this in here. You're going to need server of some sort so you can have ah Zampa. Or you can run, ma'am, There's another one called lamp. Now what this means is Mac os X Apache, My SQL PHP python. Ah, this one is not ma'am. I met Wamp. This one is Windows Apache. My SQL PHP and lamp is Linux Apache of my SQL PHP. Now it really depends on your operating system. You can use example on all three of those, but typically this is a Mac one. You can use Wamp on windows and you can use lamp on Lenox such as you bun two or fedora or w and a really any sort of flavor of the next that you want. So you're going to need these. You should already have zap set up. We we had a lesson. Ah, few videos ago about Zampa and where you can get it from. And for now, these air the only three things that you need You need text editor. Like what I have. Ah, that you can actually see my code so you can write your own code you need get, um, just because it's a good practice. Ah, and you definitely need a server. Otherwise, you can't execute any PHP on your computer at all. So your task for this video is to get a tax editor if you don't have one already created, get hub and a get lab account and set up a server with whether that Zampa wemp or a lamp I'm also using docker so you can go to my, uh, get hub repository could get hub dot com slash Caleb Holley and slash PHP dash docker and you can get started with Docker as well. It's the way I'm doing it, but you don't necessarily need to do it that way. If it's a little too difficult for you, stick with Samp samples the easiest one. So again, get a text editor, create your get accounts and get a server running. And just make sure that you can execute a PHP file, because after this, we're going to actually start writing some PHP. 11. Documentation : I'm going to teach you something that a lot of other PHP teachers tend to just totally forget. And that is there are documentation for basically everything other. Any package you install any programming language you write. Basically, everything has some form of documentation. Now the documentation may be very scarce. It may not be very well written, but in the case of PHP, their documentation is actually very very. I guess strong is the word. I would use eso if you head on over to PHP dot net. You'll see a page that looks something along this I it's not, you know, I know it's not a good looking website by any means. Ah, lot of documentation, websites or not, but the power is not what it looks like. It's it's what is written on here. So throughout this course you're going to see a lot of functions, a lot of different things that I am using, and you may not totally fully understand what I'm doing or why I'm doing it or why I throw in a certain parameter into a function. Caleb, what's a function? Don't worry about that right now. If you weren't totally familiar with what a function is or what documentation is or any of that stuff. That's a OK, because right now I'm just arming you with something that is going to help you a lot in the future. So if you head on over to PHP dot net, you'll see a page like this and you can type in basically any function now for me. I'm going to just type in date because I know that this is a common function written in PHP . Now, the search bar. You can see that there. 73 results for functions, six results for classes and one result for extensions. We're going to ignore what extensions and classes are right now. And we're just going to go to date now in this page. And this is this is a page that you're going to reference a lot as a PHP developer. This is probably the most common page that you're going. Teoh, you're going to read in the documentation just because there are so many options and I'll show you what I mean in just a moment. So on this page, we see date, we've got the date function in here again. If you don't know that is That's totally OK. I'm just setting you up for success right now. There are parameters in here, and these parameters take, I guess, is one parameter is is formats, and it takes a series of different formats. Little de capital de little J Lower L A Capital and Capital S W zed capital. W f I mean, this list goes on and on and on. And by no means will you ever have to remember all of this. This is absolutely insane. You don't have to remember that. And this is why the documentation exists. So what this lesson is all about is basically, if you ever get stuck writing PHP and you can't remember what rule exists or of certain function or how variables look or what ah, class construct her looks like or what a constant looks like. Guess what? That's totally okay. Everything. I'm going to be teaching you in this course you confined in this documentation, it's just this course will lay it out a little nicer for you. In a way that doesn't seem so overwhelming. Because if you look on the right here, these are all the different date time functions like there are a lot of them. What do they all do? Do you need all of them? Is this the right way to do it? Would you rather use a function or a class? I mean, these are all questions that hopefully will be addressed to you in your mind that will be answered for you. Throw it the rest of this course. But this last one right here is all about the documentation. So if you ever see me type something like this in PHP Echo Date, month, day, year. And you think, Well, I don't remember what m Day Watt m d Why is that? Could be month, day year, obviously. But we don't know if that's going to be the number. Does that does a month numbers start with a zero, not start with zero. Does the day start with you? Not start with zero. Is the wind just last two numbers? Well, fits. Take this as an example and let's go take a look. So I had capital m little D capital. Why little d day of month. Two digits with leading zeros. So this would show 01 all the way to 31 it won't show one. It won't show to. It'll show 01 or zero to now let's look at month I wrote Capital M a short textual representation of a month, Three letters. So this isn't even the full month. This isn't even the number the numeric value off the month this justice Jan Feb Maher Ah, a pr j u n for Joon jae ul for July D. C for December. Those short kind of those shorthand methods for months is what this would produce. And let's take a look at why I did capital. Why? And this is a full numeric representation of a year. It's four full digits. So we see this would be like 1999 or 2018 or 2019 for 2020 if we did little why this would just show the last two numbers. So this is why the documentation is really, really important, and this is why you need to be not familiar with the entire documentation. But you need to be familiar with the notion of I don't know everything, but I know where to go and find it, because that's the real power behind Web development, and I will let you in on a secret right now. No. Okay, look, don't give away the secret. So one thing that Web developers basically never, ever tell you and they never want to admit is they don't know everything. K a python developer doesn't know 100% of Python. It's It's just too large. Okay? I am a really good PHP developer. I don't know, 100% of PHP. I know a lot of it, but I certainly don't know 100% of it. If we looked through all of these functions, could I tell you off the top of my head what every single one of them does and all the parameters and what it returns? No. Absolutely not. And hey, surprise. That's totally okay. You don't have to know all of this. That's why the documentation exists. So what? I would like you to do your task for this lesson, if you will, is open up PHP dot net and just type in dates. Go into the search bar type in date, click the 1st 1 or maybe go explore something else and just take a look at this page. This page, albeit this page is actually quite ugly. This page actually has a lot of information on it. You don't need to understand all of it. We're going to dig into this, I promise you. But you need to be familiar with the documentation. All right, That is it. I will see you in the next video. And don't forget, you don't need to know everything. That's why the doctor here. 12. PHP Syntax: welcome to your first PHP lesson. Everything else was just getting ready. Setting you up for success, getting PHP actually installed on your on your hide, Not your website on your laptop or on your desktop. And if you've made it this far, Well, this is where the fun starts. In this lesson, we're going to learn what the PHP syntax, actually. Well, looks like what? The syntax. Hey, that's great question. What is the syntax? Okay, well, a syntax is how a programming language is actually read by the computer. So in PHP, there's two things to know PHP always opens with. Well, it looks like this. And let's just take that a little bit slower. So you've got your So you've got your less than sign, and then you've got a question mark, and then you just type PHP. You can see my auto complete thinks that there is a lot more in ad there. There actually isn't and wallah, you have started writing PHP. Next thing to know is, any time you echo something to the page, you need to encapsulate it or basically put ah, quotation or an apostrophe around it. So what? That looks like is. I'm going to use a quotation here and there is a difference between quotations and apostrophes. But don't worry about that right now. I have a lesson plan for that a little bit later. So if we just write echo quotation and so I'm using sublime, by the way. And as soon as I opened, one quote is automatically puts another one at the end. Your editor may or may not do that. C type echo. Hello, world. I ended with my quotation That was actually a poor highlighting job. So I've got my quotation at the end and I've also got a quotation. You can see it at the start and it always ends with a semi colon. All your PHP lines need to end with a semi colon. Your line can be as long as you want. It could be 300 characters long, if you really want. I would prefer if you didn't do that and PHP while it's being read by the computer by your server, your server is thinking. Okay, well, this is all one long line. I'm going to execute this all is one command until I see that semi colon. If you don't put a semicolon. PHP has no idea what to do, and you will see errors. So always put that semicolon at the end. Next, we have variables. Now, if you're familiar with any other programming language, you're probably familiar with the concept of variables. Now, if you're not familiar with variable, well, that's okay. Just think back to high school math. Don't worry. We're not doing high school math. But think back to high school math. When you are a teacher, would be like Here's this algebraic equation and you have to basically reduce this equation so you can find X. Remember your math teacher always saying, Find X grow. We're not gonna find X, but that's what the variable is. X is a variable, and it's a lot easier to do in programming that it is to do in high school Math. So very well always starts with a dollar sign in PHP. It never starts with a number. It can start with an underscore, but it should always start with a letter. So no special symbols, nothing like that. And you can see that I type this name that's a regular variable is equal to, and my name is Caleb. So to assign that variable is an equal sign and we'll get into variables. I promise you, this gets a lot easier. We're just quickly running through this very, very quickly. This is the data that it's supposed to echo, not echo the store. Echo is a little bit later. Ah, and then we finish that line with a semicolon, not a regular colon. A semi colon. Now you know what a variable looks like in PHP. If I wanted to echo that variable, I would echo name something like that. And while you're echoing things, this is the power behind PHP. This is the true power behind PHP is. You can write all sorts of HTML within pH. But you can make your website completely dynamic this way. So I'm going to write h one and echo my name. And then I'm going to close my h one tag and that's it. So my page will now say, Hello, world. There's a variable named Caleb is going to open an H one and close an H one and inside of it's going to say name now to close my script, I type question mark greater than symbol, basically the opposite of this and my script is complete. So now I can save this. And this is what the page looks like before anything happened. I'm going to refresh the page and we're going to see Hello World and Caleb. Now let's take a look at the source. It says Hello, World H one Caleb H. One, just like our code says hello, World H one name, which you can see is the variable. And my editor sublime is actually highlighting both of them is equal to Caleb. So Caleb gets injected into here and then close my h one tag, and that's a PHP script that is as easy as PHP gets. And ultimately, that's all there is to PHP. Now we're going to get into different kinds of variables and data types and functions and classes and all sorts of awesome programming stuff. But at the end of the day, you're writing a PHP application because you're building a website and that website, just like every other website in the world, has to use HTML. So there you go. That is Ah, I guess a crash course into PHP syntax. This whole thing is called a syntax, by the way. So you've got Ah, your semi colons. You've got your quotations. You've got your opening and closing. PHP tags all of this together. Bundle that into a package and we call that syntax. Now, your task for this lesson is create a new file minus called Index up huge being. You can see it right up there. And I just want you to open a PHP tag and you don't have to understand, echo. But I want you to do something like this. Type echo. My name is and then insert your name. Don't forget your semi ical. And don't forget your quotations. They have to be the same on both the beginning and the end. And don't forget to close your tag. Save that loaded up in your browser. So go to local host slash index PHP or my cases. Local host Colin 8000 slash some folder name because I've got this in a different folder. Folder Lessons folder 90 PHP, syntax and then index dot PHP. So go ahead. Give that a shot. Once you have done that, which really shouldn't take that long. Hopefully if you get stuck, don't forget you can ask questions. I'm here to help. I've also got a group called Learning Skoda Facebook. Thousands of Deb's in there. We're all willing to help you out. But once you've done that, head on over to the next video and let's learn something new. 13. Echo/Print: Howdy. Howdy. Howdy. Let's take a look at Echo in that last lesson. If you watched it, you saw a lot of this. Actually, that doesn't look highlighted. You actually saw quite a bit of this test Basic PHP, syntax and this weird little echo statement. Now, if you've ever written in any other programming language, often you'll see print or you'll see something along the lines of Prince with parentheses around it. Well, in PHP, we can actually do both. We can do print. Let's just save this and refresh. And it says, Test on you. I'm gonna zoom in so you can see this make this huge for you. And we also have echo test two. I say that refreshes says test and test two. So this is the 1st 1 This is the 2nd 1 So, really, what is the difference between print and echo? Well, there's a lot of speculation out there. Should you use printer to use eco PHP Developers have sort of just resided to using echo, and it's based purely on one principle. It is one letter shorter than the word print meeting that if Prentice five letters and this is four letters it's 20% faster. Basically, that's what the math boils down to. Also, in PHP, we've just written the word echo forever were echoing something to the page. So that's the difference between ECU in print. You won't see me use print, probably it all through the rest of this course. I will be using echo for everything. But if you come from a programming language that doesn't use Echo, just think of print as echo. So print is equal to echo literally the same thing. Now here you can see we have an opening quotation of closing quotation and a semicolon. When the last lesson about syntax learned all about that, well, let's get rid of that. And let's use regular apostrophes. Hello world. I use apostrophes instead of quotations. I save and refresh and guess what? It works just the same. So what's the difference between a posture, freeze and quotations? Well, I'm gonna keep you in suspense for a little bit, because we're not going to learn about that just yet. There's a few other things we need to learn before we can get into that, but for the time being, you can. You can consider these to be the exact same. Now what if I type? Hello, It's nice to see you. You can see that my color has changed. My editor thinks something is wrong. It's probably correct. Sometimes it's not correct, but is probably correct. So if I refresh the page Oh, I get a 500 error now a 500 air and you can see that because it's those little http ever 500. A 500 error means something went wrong while it was trying to run the program at it could not finish. Now, if you're using something like X debug, you can figure out exactly what this is. If you have syntax highlighting in your editor, which, by the way, if you don't, I would highly recommend getting some sort of syntax highlighter. There's tons of plug in for sublime, although Sublime comes with a PHP syntax highlighter built in. Adam has syntax highlighting. V s code has syntax highlighting syntax. Highlighting is basically well, I'll just remove this and my my my text here. My string Don't worry about what a string is, but my text here is all green. You can see that echoes orange and my semi colon is white. So that's what syntax highlighting is. So if I throw this back in here, how on earth do I write this? Because I can't get this page to display now. Well, this is something you're going to run into. Ah, lot. This is very, very common. So we have two options here, and this is the simplest one. Option one is change your outside apostrophes to quotations. So they're not the same as the one that's being used on the inside. So if I refresh Hello, it's nice to see you. Alternatively, I'm gonna changes back to apostrophe, so we're not using a quote. Refresh page will get the 500. There it is. We can do this thing called escaping. Now we're going to learn all about escaping down the road. This option is a little more advanced for you right now, but all we do is add a backslash and you can see that this here has turned into a lighter green slash yellow we color. Meaning I can now save this page. Go over here. Refresh and whoa. You notice how that backslash is not visible in there. That's called escaping. This means don't render this as the same as this apostrophe. This backslash is saying, Hey, this apostrophe right here, that one is just know possibly. It's part of the text that I want to render to the page. Just use it normally. And if I wanted to throw a bunch of backsplashes in here like this, save it. Nothing's going to change, but and we'll get into this with escaping. If I add two of them in here, you only see the one again. That's that's something for the whole escaping lesson. We'll talk about that in the future, but you now know of two methods to solve this and again, this is a very common problem. Now your task for this lesson is to just echo something to your page. Don't forget. Open your PHP tag. Echo, I would say for now, use quotations. So you've got an opening quotation closing quotation and sme colon and then put some text in there just like you did that last lesson. It's good to get this practice underneath you because the more and more you do it, the better you'll be. The faster will come to you. Don't forget your closing PHP tag loaded up in your browser. Once you see that you are good to go to the next lesson, 14. Code Commenting: Hey there. It looks like I haven't lost you yet. That's good news in this lesson. Let's talk about comments now when you begin to create bigger programs and bigger websites , eventually you're going to have ah, lot of code. We're not talking hundreds of lions. We're not talking thousands. You might have tens of thousands. And if you're using third party packages, you might have millions of lines of code to deal with. And how do you read all of that code? Well, you can't just open up someone source code or 10,000 lines of code and start reading through it because that's gonna take you forever. And then you gotta figure out what everything does not. No, no, that's no way to live your life. So what you want to do here is add comments to your code and a comment can come in three different forms in PHP. Now the 1st 1 is just like this. This is a title, and when I save and refresh the page, nothing shows up. And when I view the source, it still only says H one comments close H one. So what this does essentially is nothing now. PHP has this cool little rule where you have all the white space in the world where you can literally use 1000 lines in your in your in your source code in this index dot PHP file and it's not going to make any difference. I'm going to refresh the source. Look at that. It's still only shows one line, and that's because it is considering everything in here to be one line. Well, one line of HTML, it's actually multiple lines of PHP. No, I was gonna do that. Clean that up a bit. So this is a comment. The first style starts with a number side or, you know, as you're probably familiar with this looks a lot like a hashtag. So this is not technically the proper term. But I'm gonna call this a hashtag comment. Now. There's another kind, and it's the double slash so we can write Echo test test comment, and this one will comment out anything to the right of it. So and you can see all my comments or blue, by the way, if I comment out this and refresh my page, we're just looking at the source here, but I can refresh the regular page for you, too. Nothing has changed, and that's because all of this has commented out. But if we remove this one, there we go. We can see that test is in there. And when I refresh the page, we can see that test comes after comments now as a little refresher. If you're not totally familiar with HTML, that's okay. This is not an HTML course. But if you're wondering Caleb, why does comments show up at the top and test shows up underneath? But in the source code there, side by side? Well, that's because H one is called a block element, doing air quotes here, block element. And that means it's going to take up this entire section here, this whole section and anything any other HTML comes after it gets knocked down underneath it. All right, let's get back to the PHP now, I said. There's three kinds. Let's look at number three. Number three is a multi line comment, so this will only ever comment one line. Oh, by the way, we can also comment the entire line using the hashtag comment. If we put the comment at the beginning of our code Not gonna do that, cause Well, I think you get it by now. Now, let's say we have another line in here. My name is Caleb. Save Refresh. It says test. My name is Caleb. And what if I want to comment out one of these lines? Well, we know we can use the hash tag one we know we can use the double slash one, but if I wanted to come out Oh, comment. Oh, both of these. I could actually do both. I could just use the hashtag one or or a double line and Kuala they go away. But again, that's no way to live your life. Because if you have 100 lines of code that you just want to comment Oh, because you're debugging something you want to use the slash asterisk and you can see that it turned all of my code blue. And if I save and refresh, nothing shows up at all. But if there's something else in your let's let's say, Hey, guys, I want hey, guys, to show up in here, display me. Refresh the page. Yeah, it's not showing up. It's not showing up in her source code. either. The problem is because this is a multi line comment and we can close it with an asterisk slash. So the way we open it, it's the exact opposite. A lot like how we open PHP with something that looks like this and we close it with the opposite. We opened a multi line comment with slash asterisk and we close it with asterisk slash. So now when I save and refresh the page there we go test and my name is Caleb does not show up at all. But we have comments and we have Hey, guys, display me now. Your task for this lesson is to echo 345 lines of text. It could be anything you can't say Hello World exit comments. You could put some HTML in there, and you could experiment with that if you like, But I want you to comment one of your lines with this hashtag comment. I want you to comment out another one using the double slash comment, and then I want you to comment out one or more lines using the multi line comment. So once you're done being a pro with these three different kinds of comments, let's head over to that next video 15. Variables: Oh, hey, Welcome back. Let's talk about variables. A couple lessons ago, we were talking all about variables and sort of what they are. And remember, always like your mouth teacher was like Find X And you were like, Now I don't want to find X. Don't worry, we're not finding X. But variables are a very important part of programming languages. Now we're not doing algebraic formulas were not doing linear regression. We're not doing anything complicated. Fact. At this point, we're not doing anything mathematical were simply assigning a variable so that we can use it more in one spot. Now let's go ahead and create our first variable. So variable does not start with Echo that was have it from a couple of videos of writing echo. So many times. A variable starts with a dollar sign. So let's type name now. If you remember, maybe you don't. Maybe you skipped over that that last lesson or a few lessons ago, where we talked about variables. Let's, uh, rewind real quickly, so variable starts with a dollar sign. It cannot have a number as its first letter. It can be name one, certainly, but it cannot be one name and you can see that my my syntax highlighter went from typical gray to white, telling me that it's different for a reason, so it cannot start with a number. It cannot start with any special characters. In fact, it has to start with ah, letter or alternatively, and underscore. Now I would suggest staying away from underscores because I had conflicts with something called Super Global Variables and Private Variables or private Properties will get into all of that down the road. But for now, maybe just stay away from using underscores because it can be a little bit confusing. So I'm going to write Name. Oh, and by the way, name is not the same as name. Where the capital end is not the same as name all caps, thes air, three different variables. So let's assign this first variable. And that's what is called a signing. That question mark, not that question mark. What am I saying? Caleb, Get it together. That equal sign that we see here that I have highlighted is saying that we're assigning a value to a variable. So let's say the name is going to be Caleb, and if you're doing these exercises. If you're going along with me while I make these videos, feel free to use your own name. You don't have to use my name. Remember, it ends in a semicolon, and I'll I can type name. Remember how eco works We just act was something. But instead of using quotation marks around it, we don't No quotations, no apostrophes who we just use. Dollar sign name ending with semi colon. Now I'm gonna refresh the page. Now it says Caleb Sobule. Yeah, that's a variable. But if you're asking. But if you're asking Well, why would I write this when I could just write it? You know, this way. Well, that's because we can use this over and over and over again. We can say echo, name and copy and paste this over and over and over again. Manager shows up over and over and over again. Okay, Not particularly useful, but we can also put it in our eco statement. So if I just do this and refresh the page, it doesn't say Caleb anywhere on there. But if I wrote my name is the variable in there. So we've got quotations, Remember? Quotations are important. So starting quotation, closing quotation. Oliver Syntex looks good. Says my name is and this matches this hit save and we'll see that it works perfectly. Says my name is killed. It's the equivalent to writing, Caleb. It's the exact same at this point. So why on earth would we ever use a variable? Okay, well, let's say we're writing a short little application. A little website that creates a story for someone. And you want that name to be completely dynamic. You say hello. Let's actually I see this. Hello, Caleb, please. This Well a Hello, Caleb. We can also put some HTML in here. Br echo. Uh, did Ah, my name is I don't know, Jacob. I think you make that a proper sentence. And now we can write name. It's nice to meet you, but a space there. Otherwise there won't be a space. Hello, Caleb. My name is Jacob. Caleb. It's nice to meet you. Okay, cool. So now we've got one name in two places. Not really as dynamic as you thought it was going to be, right? Well, that's because right now we're still in some of the boring phase of learning. What variables and what not actually are. But if we fast forward, like, 20 lessons from now and just don't mind what I'm writing here, I'm just going to show you how this actually it's very dynamic. We type in this super global variable mentioned in the last video. And I type in a question mark. Name is equal to What does my name on to be? Maybe my name is Nathan, right? Look at that. Hello, Nathan. My name is Jacob. Nathan. It's nice to meet you. I could put anything in here literally anything. Hello? Literally anything? My name is Jacob. Literally. Anything? It's nice to meet you. So this is the power of a variable. Now again, Do not worry about what this is. What I have highlighted has nothing to do with what we currently know. So if you're looking at that and you're like, Whoa, that's I have no idea what that is. Well, remember, you have two options. You can ignore it until we learn about its in a few lessons. Well, quite a few lessons, actually. Um, or you can look up What a super global variable is on stack overflow. You can Google it. I'll even type it out for you. In case the audio quality is not fantastic. It's called a super global variable. Variable. Second times a charm, right? Look that up. Or look up the dollar sign. Underscore. Get in the PHP docks. You can do that. Otherwise, feel free to ignore it and we'll get to it eventually. Now you know what a variable is. You know how to assign a variable? You know how to make your name as a variable. You can also do something like age is equal to 13. I'm going to get rid of this. Hello, Caleb. You are? Here's old. Hello, Caleb. You're 13 years old. What's actually very, very incorrect. Flattering, but very incorrect. You are, Let's say, 25 ish. Wow, that's also incorrect. Your 30 ish. You were 30 ish years old. Now if I wanted to use just a number, Guess what? We can use just a number just like that. And there we go. That's variables now, but I would like you to do your task for this video, create a new file. You don't have to worry about the header here. I'm just adding that so you can see what we're doing over here, but create a new variable. Call it name calling age. Call it whatever you want. A sign of value to it, and then echo it out. It can be as simple as as simple as this. So we have variables. Name, echo name. That's all we need. So once you've done all that and you've got it working in your browser, go ahead, Click that next video are You know, wherever you're watching this video head on over the next video, and we're going to learn, you know, a little more, a little more willing to take the step by step. We're definitely getting there. These are things you probably didn't know too much about, you know, just 10 15 minutes ago. 16. Data Types: Hey there. Welcome to another lesson on PHP and this lesson We're going to learn about data types. Now we know how to echo something. We know how to comment stuff. We know how to create a variable in echo that out. But when we were writing a variable Oh, actually, I Here's something that I forgot to mention You can have multiple opening and closing PHP tags throughout your PHP file as many times as you want. So where I have PHP opens, PHP closes PHP open speech. We closes. I could put some stuff online, too, if I wanted to write stuff to refresh the page. There we go. I have as many of those as I want. So the fact that I'm not using one big PHP opening and closing block that's totally okay. Let's look at data types. No data types. There are several different kinds of data types. There are strings, so a string is a sentence. Think of a sentence like a string. So anything that has letters in it, anything that could have a space in it, anything that could have special characters like an apostrophe quotation exclamation mark. You know Caleb would be a string and let's let's do another one. Um, my name is Caleb. Look, that would be a string OK? And in fact, let's do this. Let's let's do it this way so you can see what's going on. String is equal to Let's call it the end of the line at that semi colon. Never forget that semicolon. So that's a string. Up until now, we've only been writing strings. If we said age was 30 well, that's not technically incorrect, but there is a better way to do it now. This one can just be a straight number as long as there's no letters, no special characters. So no exclamation marks, no periods, no dashes or anything like this. So ah, formatted phone number where it's like 555555 level of level. I was something like that. Unacceptable. That does not count for this data. Put this data type now. This data type is called an integer int for short, and this one, as you can see, does not require quotations or apostrophes around it. On Lee, strings require those, and that's because it has to account for things like spaces, numbers, special characters, etcetera. Next one we have is a float. Now this is basically an integer. In fact, let's not use age. Let's call that into Ah, float is essentially an integer with a decimal. So 30.0 30.1 30.12 Anything that has a decimal in it would be considered afloat. So let's do this. Let's do 3.14 the float number that we all know about. And this is called a float in some programming languages. This is also called a decimal. Now, the next one we have would be a Boolean, and this one could be true. Good to do. True, false. I am just butchering this code here. They're with me. Good thing I didn't refresh my page. Otherwise I would have seen an error. So Boolean is a true or false. You're going to see a lot of these in programming. Essentially conditional statements is what makes the world go round. For example, if my age is 30 or higher, take a certain action. If my age is 18 or under, take another action. I could say something along the lines of Actually I also made a table there. Lower case T is generally the one that we use. I could also say if float Ah, if I could If I said pi is equal to 3.14 then make a circle. Otherwise don't make a circle right. These are conditional statements. We'll talk all about conditional statements in a bit. I know I keep saying this. I keep saying we're gonna learn about We're gonna learn about it. But we have to learn things one step at a time. So a boolean is Is something true or something false? Is the sky blue? Well, I'm looking outside right now and this guy is great, so that would be false. But it's on a nice day. The sky might be blue so we could say sky blue True if the sky is blue or we could say Sky blue is false If this guy is not blue now a Boolean is you have heard this term before binary. There's only two options. It's yes or no. It's true or false. On the last one. I want to go over with you quickly is an array and a ray. Now this is ah, list of variables or list of well, values, actually, cause they don't necessarily need to be variables, and this one has crack it. So one groups two and three and let's just make that wee bit smaller. There we go. Now we can see we have different data types. We've got a string uses quotes. An integer is just a flat number 12345 Something like that. Ah, float has a decimal. A Boolean can ever be true or false. And an array is a list now an array. I forgot about this, actually, um, I wanted to mention about 35 seconds ago that it doesn't necessarily need to be of value either. A value being basically a string you could write anything you want in here into which references the number 30. We could also type in pie if we wanted to, as in 3.144 float, which would be the same thing. Ah, we had type in Boolean And let's just move this to a new line. So we've got a strength for an integer We've gotta float. We've got a Boolean in there and all of this combined makes an array, so save that refresh the page. Wow, Caleb, there's nothing there. Obviously, there's nothing there because we have not echoed anything back to the page. All we have done is assigned a bunch of variables. Now these are all variables. They have different data types. So if I wrote, I go string and let's Ah, let's add a B are in here. My name is Caleb. Copy that line, and if I wrote it, this is going to say 30. And if I copy that line again, next one will be float 3.14 as expected. Okay, but here are some tricky ones. What about Boolean? What do we think Julian's going to display? Boolean doesn't have quotes around it, so we know it's not a string. It's not afloat. It's not an integer. It is technically a word, and it breaks a whole string rule being a word. Well, let's take a look. It showed up as one. What if we turn that to false shows up? Has nothing interesting. We'll talk more about that in the future. Interesting. We'll talk more about that in the future, so I turn that back to true. And as one more example, let's echo the array and it just says array. Now, why does a race a Array wants? Because it doesn't know which value to echo. It has no idea. It has a ton of different options in here to pick. And really, you don't. You haven't specified which one is more important. Which one has a priority over other ones? You haven't told it to do anything? All we have told this array to Dio is store four pieces of information in it. Now, I'm going to create a lesson a little bit later about how we can access all that information from an array so that we can actually make sense of this. But for now, But I would like you to do as your task. I would like you to write a string variable, an integer variable, afloat variable and a boolean variable. The array one you can leave out because we're gonna talk about a raise specifically a little bit later, and then I want you to echo all of these out. And in fact, what I'm going to do is I'm going to get rid of all of these and keep it like that. I was using some canned Cat Nation in there again. That's another lesson we're going to talk about. Concatenation is essentially how we merged two strings together so that we can echo things without having to write echo over and over and over again. We could just type like something string dot int and that will basically merge the two together and display both of them side by side again. We'll talk about that later. Don't worry about that. For now. Your task is to create a string in flute and Boolean and echo each of them to the page. Once you have got that figured out, how don't over the next video and I'll see you over there. 17. Mixing PHP and HTML : Hey there, boys and girls. Ladies and gentlemen, programmers of every variety. And this lesson, we're gonna talk about how to mix html and PHP. Now, we've seen it a little bit up until now, and this lesson should be fairly short because we've actually done it a few times. So when were mixing HTML and PHP? Remember, you've got index dot PHP file has to be dot PHP It's not dot html not dot txt not dot Js Not anything like that. It's dot PHP file is always dot PHP Forgive the typos. I'm standing a little bit away from the mic just so that you don't hear the tech attack attack of the keyboard all the time or the fan of the computer. So the PHP file always ends in a PHP dot PHP. You know that we've been doing this for, like, seemingly 14 lessons already, But if we want to make some html in PHP, all we have to do is echo Echo H one. This is a church one close H one, close my PHP. Save it Cool. H one. What if I want h 20 k? Was it a copy and paste this entire line. And did you do select all three of those and do a church to save that refresh? Look H two, By the way, how I did that in sublime. I just liked my tax and hit command D or controlled D, and it will just select the next one of that type. So if I select H one command or control D, it looks like the next one or this one. It'll suck the next one as well, and I could type in two places. Now let's get a little bit more creative. Let's do echo Div style border one pixel solid red. True to do, close that tag. And in here don't report that in dense. Remember, PHP gives you all the white space in the world so you can use as many indentations as you want. I would suggest you would ever make sense to you for right now so that your code stays nice and clean. Makes it easy for you to read Echo. Hello to make this look absolutely terrible. And there we go. Now, we've got some CSS in there, too. But you know what? Maybe maybe let's not do that. Let's do something a little bit different. Let's do make a bunch of space here. Get that off the screen and let's type regular HTML because right now we've done PHP with HTML in strings. But let's through the other way around. Let's to h e mail with PHP inside of it. And let's create a variable appear called name is equal to Caleb and in my h one I type Ph b Echo name, say that refresh. But, uh, just like that and that's actually name in there so we actually see what we're looking at. So now we have HTML some or HTML. We've got some PHP with a variable that's referencing a variable that was made outside of this current PHP tag. By the way, this was made up here. So this PHP tag closes this code up here, and it was still accessible later on, as long as it's on, the same page is completely accessible and then some closing html. So that's really all there is to it. Now, if you want to do a task for this one, this one is totally optional because we've already done this a number of times. But I would suggest creates an H one tag or a div with some style, uh, do any sort of html CSS mix that you want and throw some PHP inside of it, just like you would build a regular website. You know something along the lines of this? Let's do this style, that's you. Background color whips, color read and hello. So regular a she male regular CSS Nothing fancy. You should be fairly familiar with that by now that go name, and that's just going to say, Caleb in there. And Tut uh, we're already familiar with that. So go ahead, give that a shot, mix and match things. You don't need to worry too much about how this works, because over time this just makes perfect sense, because now you're mixing html with possibly in line CSS and PHP. I mean, if you really wanted to in your page, you could even type. Let's not do it there cause that's messy. Let's do it here script, and you could do like an alert. If you're familiar with JavaScript Now, I've got PHP inside of my JavaScript on the refresh The page did. Ah, it says my name and the code for this, by the way, looks as expected. Google. So maybe go practice. That maybe not really depends on how comfortable you are with this concept right now. If you're comfortable, let's move on. If you want some practice Cool, guess what? These videos aren't going anywhere, so feel free to pause or to stop where you are. A little bit of practice underneath your belt. And when you're ready in your own time, feel free to head on over to the next video and I'll be waiting free over there. 18. Unsetting Variables: Hello. In this lesson, we're going to be talking about how we can not necessarily delete a variable, but how we can unset the value of it. So we learned before that a variable did open up my syntax here, and we learned that a variable looks like far is equal to something like this. Very simple, straightforward variable. Now this part here, that is, that's the value. That's what we call a value. And this value can be unset. So if in here I typed Echo and I refresh my page, it says killed on. That's also in H two because they didn't close that tag. So let me just quickly fix that up there. Go says Caleb, I'll make this bigger so you can see this now if for whatever reason we want to unsettle variable on, this happens from time to time. So this is a good thing to know we need to be able to get rid of the value. So the way we do that is by using a built in function in PHP called unset, and it can take a bunch of variables, but in this case, we're just going to give it the one variable. Now, if I refresh the page, you'll notice that this still shows up. And that's because in computer programming, most languages execute from top to bottom, so this variable is already set. This variable is now echoed out, and now the variable is unset. It's already been echoed. It can't can't be UN echoed so as a demonstration. Let's echo this out once more after it's been unset. So I'm refreshing my page here and nothing is happening. And we can see this when I type Echo. Uh, let's just put stopper in there just so we know that it stopped and there's nothing in there. Even when I view the source, there's nothing in there. It says. I'm sending a variable. That's my H to tag, says Caleb. That's what we echoed in here. We unsaid the variable, and we tried to echo it again, and nothing happened. There's nothing in here and then just says stopper. So that's how you unset a variable. Now, if you want to accept more than one variable, all you have to do is not variable 12. I mean, it could be variable 12 if you wanted to. I just use a comma separated list and type your variable names. Now they don't have to be var fire two of our three of our four. It could be also your name or whatever. Whatever the name of the variable is, you can unset it now. That's also works for a raise and objects and and all sorts of things. You just need to unset one particular value, and this is how you do it now. Your task for this lesson is to write your own variable. You know how to do this. Now echo that variable out. You also know how to do that. I'm set your single variable. You don't have to do to three or four variables, just unset the one variable that you've written and try to echo that out. Load that up in your browser and you'll see that nothing happens. And if you get similar results to what I have in this video, then you were good to go and we'll see the next lesson. 19. Debugging Variables: All right, welcome to another lesson on PHP. In this video, we're going to learn about the print our function. Now, this print, our function is actually very, very important because while you're learning PHP and while you're coding peach, but you're going to need to figure out how to debug. Debug is the act of basically running into a problem and coming up with a solution to Teoh mitigate or to remove that problem. Now, sometimes you'll write a variable or you have a typo and something just won't work and you don't really know why. And sometimes you don't have all the error logging turned on which you can turn on. We don't really get into error logging too much in this in this course, but you can turn your air logging on. Just remember that when you're in production on a live website to turn it off so that you're users never see those Ugly Evers. And so as an example, let's open up our PHP tags here, close them automatically like it's just a little bit bigger so you can see this and we can echo anything. We know how to do this. We know this is going to echo anything cool, boring stuff by now. So let's just jump right into printer That's type in. A name is equal to My name is Caleb. And if I type, print are and I put the variable in here, you see not a whole lot, because all that's doing is printing this name. Not incredibly useful, I know. But what if we have an array? So we have an array? We should be somewhat familiar with a raised by now. Really, It's just a fancy way of saying this is a list of things. So let's create Caleb and John and Zephyr. So we've gotten array. It's going here and changes to an eraser. We're going to print our this an array, and now we see something a lot different. So if I go into the source code here and refresh, you can see that it tells me that the array variable is an array. It's not giving me the name of the array variable. It just happens to be the same name. But we could changes to anything else, literally. Anything else. Nothing changes here. I refresh in this still sensory. So this tells me that my data type. Remember that lesson from a little while ago we were talking about data types. It tells me that anything else is now an array and that the zero index or the 1st 2nd and third items are Caleb joins effort now, knowing that and being able to see that I can say echo anything else. And if I wanted to echo Zephyrs name, I would type in two because that's the index that we see here. And when I whips and when I save the proper of age and refresh, we see his effort. And now, if I ever wanted to get John, I could also change. That's to a one save refresh and it says John. So now this is helping me debug things. Now this is actually a terrible example, because I can see the array. I can see that this is Index zero index one index to, so that's not helpful. But if you have a larger application, let's say there's 50 PHP files and you don't know where anything else is coming from. Anything else being the array and I was going to actually rename that just for simplicity sake, we don't know where this array is coming from. It could be from any other file. We could spend some time debugging it. We could spend some time looking in other files to figure out exactly what is in here. But really, all we need to know is what the values are in this array. And we could say, um, actually, it's sort of create a new example here. So all the way down and I'm gonna comment this out and so, you know, pretend we're in, Ah, pretend we're in a new file. Okay, now we know that we have access to this thing is variable called Array, but we don't know what this is now. We could say echo, array, Refresh your page. It just says array. That's not helpful. We could try to look through it, but we don't really know about loops yet, or we could skip all that heartbreak and just just tell us what's in it. Refresh again. It tells us exactly what's in it. Then I can say echo array to I know that array Index number two is going to be Zephyr save Refresh. I can see it. And now I can get rid of this printer race. So now we're actually getting into debugging a little bit, and this is what print are is four. It tells you everything that is in an object or an array or a list. Or if it's just a plain text variable a string. It'll tell you that, too. So your task for this lesson is to create an array. Give it 234 items in there, make it names off you and your friends. Maybe some of your family and then I want you to print are so print are family members and then open up your source code. So don't just view it in here because you're gonna see something like this. But if you viewed in your source code, which as a reminder if you right click and go into not inspect but view page source, you'll see that you can actually see the source code, and that gives us something that looks just a little nicer, you know. So again, go ahead, create create a an array prints are it, and then really just take note of what it's doing here. Maybe make a mental note as well, or if you're taking physical notes. Ah, make a note that it also lists out your indices. So this is an array. This is the 1st 1 second, 1/3 1 And remember, when computers list things generally, they start at the number zero because zero to a computer is a number zero to human means. There's nothing. Those are different. All right, so once you've done your task, head on over the next lesson, I'll see you over there. 20. Better Debugging: Okay. Hello. If you're coming from the last lesson, we were just talking about the print, our function, and I'm gonna show you something might be actually a little bit easier for you. So instead of just using the print our function, which sometimes you have to go into her source code to make sense of because when things gets just spit out to the HDL to your document object model. Basically, when your browser just views a bunch of nonsense, it's going to remove extra spaces, is going to be very hard to read. And there's a better way to do this now there's a little caveat with this one. VAR dump requires actually attacked us up. This requires the X debug module. No, a lot of hosting places come with ex debug installed. If they don't, you can usually turn it on. And if you can't turn it on, then you can probably just use print. Are to be totally honest now that you know how to do that. But I'm sure you an easier way. So we're going to open this up, got a bunch of PHP in here, and I've got an array and this array has a bunch of names in it. So it's got Caleb. It's got Nathan. But let's capitalize that because it's a name and that's proper. And let's go with Prairie and let's add some more in here. Let's go with John and let's go with Moses. And if I type eco array, you know by now that this is not going to show me anything. It just says Array. That's not useful at all. Let's comment that out. And let's type print are array. This is what we did in the last lesson. Okay, so we've got an array and we've got a bunch of indices and stuff in there. OK, that's all right. And we know that we view the source. It becomes a lot more legible. But what if we didn't want any of that? What if it's gonna sort of clear this off here and make a little break? What if we just wrote Var dump and we just wanted to dump the entire variable called Array ? It doesn't have to be an array. It could be a string. It could be an object. It could be anything you want. It just happens to be that this Ray has the name of a ray. Look at this. I'm actually gonna make a smaller This tells me where my file is located. On what line? That this VAR dump is being called on, which is really good for debugging because now you know. Oh, okay. I have to go to index dot PHP. It's in the 1 70 Vier dump folder which, if you look in my sublime, is actually right here, and it's saying cold and 17 that means Colin 17 Line 17. That's where this is coming from. And now this also reads the array for me. So it says array sizes five there five items in it. It starts at zero and goes to force a 01234 If you count those on your fingers, that's actually five. It tells us the length, the length of each array item. So this is telling me that this is five characters long. This one is six characters long, this one a 73 and five and they can tell me that these air all strings as well. So now you don't have to go and print are an array and then loop through that array and prints are all of those or print our individual indices. This just tells you everything, and you don't have to view your page source because if you view your page source, it looks terrible. And that's generally how life is going to be. As a program, your source is going to look terrible. Don't ever worry about how well or how not, well, how terrible your source coaching look like. And by that I am simply referring to the source code in your HTML page, your source code in here. What you're actually writing the PHP that your browser does not see. Try to keep it as clean as possible. So far, I've been doing a terrible job, you know, do do as I say, not as I do type thing. These air purely for demonstration. Actual production code is much cleaner, so this is var dump. Far dump is print are, but so much better. If you have access to this, if you can enable it, I would suggest using this because this is just so much more informative and you don't have to worry about like viewing your source and parsing HTML on reading a bunch of HTML entities and all that other stuff just far. Dump works. So your task for this lesson is creative. Variable an array put a bunch of names and it just like we did not last lesson where we were learning about printer and then it's out of print are which looks like this. I want you to use var dump now. If this does not work, it means you do not have X debug module installed, and you might just have to ignore this this lesson for a little bit. Or you can hop on the Google and you can figure out how to enable X debugging typing. Google How to enable X Debug for PHP seven or PHP 5.6 were using PHP seven in this course, but you might be using PHP 5.6 if you're on older computer or an older hosting service. Let's go ahead, give our dump a try, and once that's all done, either will work or it won't work. I don't oversight next lesson, and we'll learn about something new 21. Type Casting: hello and welcome back to another episode of learning PHP in this lesson, we're going to be talking about typecasting now. This is something that I actually don't see very often and is incredibly important, especially if you want to eventually learn other programming languages like Python or C or Java. Now PHP is a programming language that is loosely written. I'm doing these air quotes here loosely written. That means we can type age. Actually, hold on. We can't type anything unless we have some syntax in here. Now we can type. Age is equal to 12 and we can print eco age. And when we do this, it says 12. Or if we type literally, anything else it says 12. Anything else on the front end being on the browser, we will never see the difference. But in the programming language itself, we will definitely see difference. And I remember that lesson when we were talking about data types when we were talking about strings arrays floats into, you know, things like that. Well, this one, as you know, because there are quotations around it is a string. And if we do this var dump age, I didn't make that smaller. It says that on this page online seven it was being called and it is a string. And if we take these out and now says that it's an into its not a string anymore, it's an integer. And if we said 12 25 it's now called afloat because there's a floating decimal in there. So why is this important? Well, in the future, not yet. But in the future, we're going to be learning about if else statements these are called conditional and thes can become very, very important. So, I mean, to give you a quick glimpse into what that actually looks like Now, don't feel the need to learn all of us right now because we're going to learn all of this stuff that I'm about to type in the future in their own dedicated lessons. So you actually get some hands on experience of the task. But I'm just going to show you how something works here. Okay, so if I say if age is equal to 12 Echo Hello. I am 12 years old and we set that age variable too. 12. This says hello. I'm 12 years old now. We know that age is a string, and we know that Well, this is not a string 12 without the quotations is an integer. Now, if I typed three equal signs, nothing happens. But to equal signs is okay. And again, we're gonna talk about this later and I'll get into them or intricacies of the ah, the two equal science versus the three equal signs and how the comparing all that stuff. But for now, you need to know that there is a difference. And so that difference is this 12 does not match. Whereas if I said three equal signs and age is an end and we're also checking for an integer refresh the page, it still shows up. When I used to equal signs, it will still show up and it still shows up. It's it's working perfectly fine. But again, when I put those quotations around it, it won't work with the three equal signs. Okay, so enough confusing you with all of that stuff. In the last lesson, we talked about Var dump and Bardem showed us a bunch of stuff so we could do an array and we get into multi dimensional race, which is a really fancy way of saying there's an array inside of Andre so we could say Array is the first item in this race also in array. And let's do you do, um, whips. I am not having a good day when it comes to taping today. Caleb Nathan and I'm gonna create another array, and this one's going to be do to do. I don't let's put these ones as numbers. Let's put 28 26 and fired Dump Array. Look at that now. It shows us that the array that we're dumping isn't array and there are two in there. There are two items in there. It doesn't necessarily know those items are. It just has the size to. In the first Ray, we've got a string Caleb, another string Nathan. And in the second Array, this one here. Remember that that index offset zero is equal to 11 is equal to two. In human terms. The 1st 1 is 28. That's an integer 26 that's afloat. And if we said 26.5 and refreshed, this is I said, that was a float early. I meant that's an into I got ahead of myself. But if we refresh now, now that says 26.5 this is now going to say float instead of int Taita just like that. So why is this important? Well, because in other programming languages and this is not really the case too much in PHP. But if you want to write really good PHP, you need to learn that these are different. So how do we force these to be the same? So I'm gonna create something new in here. Um, what should I do as an example, I'm yes, scared of this. Um, and let's say age is equal to 12 var dump age. This tells me it's a string, but what if What if a user puts in some information through a form or something? Some way we're taking in user input and they put in the number 12. Well, it's probably going to come back as a string, but what if we wanted that to be an integer? We have this single typecasting now I know. Finally kill if you've gotten to the point. Yep, I'm getting there. I'm getting there. Age is equal to int age. And what this does this is not actually a function. Technically, what this does is say we're now assigning age. That's this one up here to be an integer. So now when I save and refresh the page, this will no longer say String. This will say int We could do the same thing with float. We could do the same thing with a Ray and it gave us an array. It actually turned our string into an array. So now we can say eco age zero to get the age. Look, there it is. Let's go ahead and delete that we could if we wanted to turn this into an object. We haven't talked about objects really all that much, but we will be or the exact opposite. We could say 12. And let's comment that Oh, we're going to see that this is now an integer. And if we wanted to, we could also turn this back into a string just like that. So at this point in your programming development career, it's It's not important to know what type casting it's. It is important to know that there is a difference between 12 and 12 in the sense that 12 is not the same as 12. These are actually two different things. PHP again is very loosely typed. So it compares those and says, Okay, those air close enough. I kind of understand that these are the same thing, But in other programming languages, you may not actually get that opportunity and more strictly written languages. You have to specify the 12 has to be a number. It can't be a string. Now, why am I telling you this? I'm telling you this to set you up for success in the future because you're not always going to be writing PHP for the rest your life. There is a big programming world out there, and you're going to eventually be writing Ruby or maybe Java or python or node or javascript, whatever that's going to be in the future. There are differences here. And so this is what typecasting is. Typecasting essentially is. Take us out here. Typecasting is forcing a data type on a variable actually, uh, variables value. Technically. So that's all that is now your task for this lesson but I would like you to do is creative variable. Make it a string so put like Caleb or whatever your name is Put your name in there and then I want you to change that to an inter. And because all this makes no sense, I wanted to change it to an end var dump it or print are it so that you can see what kind of property it actually is, what kind of data type it actually is. And I want you to see what happens when you turn your string your name into a number. Do you think it's gonna turn out to be five because there's five letters in there? Do you think it's going to be, um, won or zero? Oh, I missed Ah type as well. You can also change it into a bull or Boolean that's true or false, yes or no. Eso Go ahead, turn your name as a string into an int and see what happens. And then you'll probably be a little bit confused after that and then go ahead and do the same example that we did in this video where we use instead of, you know, I'm not even take that out. There you go. Let's go ahead and try this one out afterwards and see that 12 as a string actually turns into an inter. All right, cool. We'll see you in the next lesson once you're all done that and we'll learn something new. 22. Arithmetic (Math): Okay. Hello. Welcome to another lesson on PHP. We're gonna be learning about arithmetic or as I like to call it, because why not math? Now, don't get scared. And don't get too excited because we're not going to be getting into anything super complicated. We're not going to be getting into, uh, linear regressions or or calculus or anything like that. We're just going to be talking about how do we add minus subtract, divide and add exponents to something in PHP? Because a lot of times we are going to be doing some basic math. For example, you're creating a dashboard and you want to see the number of users. And maybe you're doing a prediction thing where you want to see, um, where you have grown 50 users at 50 users per week and that grows by 10% This plus 10% every week for four weeks or something like that. So that's not really advanced math. That's more advanced in what we're going to do in this lesson. But I'm gonna show you how to take care of all of that stuff. So that's just go ahead. A little break there, renamed the Back to math because that's where I like to go. Because arithmetic is that dashboard arithmetic is math. Open up my PHP syntax. Give me some space toe work. And if I said number is equal to 10 and I said, Echo number shows me 10. In fact, let's do something better. Let's do echo H four results. Okay, so we know the results are gonna be down below here Now, what happens if we want to add 10 to this number? Well, we could do number is equal to 10 whips, 10 plus 10 and now we're going to get 20. But that's not useful because you don't you don't know where these 10 numbers are going to be. The whole idea behind programming is that your data becomes fluid. It becomes dynamic. If you already knew that your number was 10 plus 10 at all times, you would never actually need a programming language. You could simply write 20 on your page and get the exact same result, because that's never going to change. So what we need to do is we need to say, Here's our base number. We're gonna start with 10 and we're going to create a new variable called number using that base number. So base number plus 10. So we got a base number of 10 and now we've we're adding another 10. In fact, let's not do that so we don't get confused with that last example. Let's add 11. Now, this will say 21 refresh page and it says 21. Now why is that? This here? See how these are referring back to each other? This is saying, basically, instead of based number in there, it's just saying 10. It's referring back to the value now in high school math. You're always told to, you know, do of this formula or something. Uh, and the teacher would always say something along lines off, find X, or find the value of why. And you were like, Why would I ever need to know this? Well, this is one of the times. Now, if you don't know if you don't remember how to do any of that two things. One Khan Academy is fantastic. If you're interested in the math, if you're not interested in math, don't worry about it, because this is actually super super easy to grasp. So now we have our base number. We've got a new number in here called number and always doing is adding 10 plus 11. And that's how we do our basic arithmetic. We just add a plus sign now to minus it. We get negative one because we're saying 10 minus 11 is going to be negative. One again. Basic math if we multiplied it. So the multiplication is the asterisk. So if you hit shift eight on most keyboards, you'll get that little asterisk sign. Ah, it's not the X. Don't don't confuse it with X when we write it on paper, multiplication is often X, but in computer programming we use an asterisk. So let's do this. Do 1.5 and that'll give us a float. And by afloat, I mean an integer 1.55 would give us afloat. So all this is doing is multiplying. 10 by 1.55 gives us 15.5 C. You don't need to actually know this. You don't need to know the math. You don't need to know if if that answer is technically correct, you just need to know how to do the arithmetic operations. And let's divide this will give us a weird number there. You so 10 divided by 1.55 We get six point 4516129032 to 58 Pretty straightforward stuff there. But if we wanted to exponents something so let's say 10 to the power of No, let's not do that. Let's do three because this will be easier to understand. I think 10 to the power of three we use to multiplication signs in a row. And let's do three. Oh, Page 500 on May didn't have my colon in their refreshed 27. How did that get? 27. Well, exponents are essentially you've got three times. Three times three. So three times three We know this is already three times three is nine times three and then nine times three is 27. And that's how we got that exponents. So exponents is one of the harder ones. There's also another one in there called module ISS, and what module is is is the remainder. So you remember when you were doing math back in? I don't know greed. Six ish, and it was, like 10 Divided by three gives us 3.3. But what is that remainder? And so it was like three goes into 10 3 times, with the remainder off one. How do we get that? Remainder in programming and in most programming languages, this is the same for most programming languages. We use the percent sign. This is the module ist sign. So this is not the percent of something this is saying. Get the remainder of and now we see the remainder of that is three. So this is saying three goes into 10 three times, which we already know that off the top of our heads. So 3699 out of 10. And then we invert that so we go or inverse that rather we go 10 minus nine is one. Now, if that was way too complicated, all you have to do is remember this little percent sign it'll do all that math for you. So that is arithmetic in PHP. So what I would like you to do is I like you too. Ad subtract, multiply. Divide. And I would also like you to add an exponents and a module ist, and I'll just throw that in here. Your task. Add, subtract, multiply, divide exponents and modulates. Um, print out those results to your page and see how they work. I think this will be fairly straightforward for pretty much everybody. Once you're done that well, head on over to the next lesson and ah, I'll see you over there. 23. Constants: all right. And this lesson we're gonna talk about something called a constant now a constant in essence, is a variable that can never change. And it is a basic variable. He could not be like a multi dimensional array. It cannot be, Ah, an object or a set of classes will talk about objects and all that stuff. When we get more advanced down the road and essentially, that's all it is. It's variable that cannot change. Okay, so let's create an example. Your let's open up my PHP syntax. And we've got a regular very variable variable called Caleb. Right. We know all about these, and we know that if we wrote Echo whips, caps, lock, echo, vire and then we said Viers equal to Nathan Echo of our This is going to say, Caleb in the Nathan Caleb a thing just as expected. But what if we want a variable that can never change? And this is good for config files? Uh, certain settings never need to change. Um, and admit email address may never change. And so what we can do is we can set a constant with this function called define. And so we give it a string, and this is what it's going to be used as later. And we say, Um, it's make it name and his name is going to be Caleb Now notice that I'm not setting a variable. I'm not setting and Ray or anything. This is not happening. It is just simply a function in my code that says Name and Caleb. And if I echo name, guess what? It doesn't work because this is not a variable. What it's looking for is just a constant. So a constant does not have that dollar sign in front of it. Now if we echo this boom, there it is, Caleb. But what if I said name is equal to Nathan five hundreds on me. That error is if I had proper error. Logging set up right now. That error would be saying you cannot either have a variable without the name are without the dollar. Sign in front of it, or you cannot rename or ah, revalue or repurpose a constant something that's already been defined. Something go ahead, remove that refresh page. Cool. So when we're dealing with variables, we can also check to see if a variable is set, right? We can say Caleb, And if it's that again, we'll talk about this in the future. For sure, we definitely will, he said. If that's set, Echo, Caleb is set and this will say Kayla beset. There we go. But if we said if it's that constant, nothing happens again, we just get this stupid air this, http, ever 500 That means there is a server error. What is it doing? Well, instead of saying is set. This one has a different definition. And again, don't worry about remembering this part because we'll cover this in the future instead of define, we say defined there, you because this is referencing the string. This is not This is not the name of variable. This is simply a string that is stored in the memory that can not ever be changed. So So that is your introductory lesson to constant constant can never be changed. Once it is set, it is set. You do not unset it. You do not change its value. It is there forever. For as long as the script is running and again, that's really good in config files. Now your task for this lesson is to create a constant echo it. Try changing it. Echo new constant. Just try that. So create new, constant echo that constant out like we did here. Try changing that constant. Try changing it any way you could possibly think of, and then echo that new content out. 24. Concatenation: All right, let's talk about coming. Katyn Nation concatenation again. For whatever reason, programmers like to use big fancy words. Really? Just means you were joining data together. Now, we've seen this a few times. Um, I have Ah, yes. I've created a few examples where I use, um, if else statements things that you haven't learned yet. Can Cat Nation again things that haven't learned yet? I've sort of been using them to get you use to how they look and how they act without formerly understanding how they work. You're just sort of dabbling your toe and the realm of the unknown right now and that is OK , so in this lesson, we're going to learn what can Katyn ation formally is. So I'm gonna start, as always. I'm gonna open up that PHP syntax and I'm gonna write. Name is equal to Caleb, and I could say hi, my name is Hi, My name is Caleb. So, in a sense, this is a form of concatenation, but not not proper concatenation. This is really just adding it variable inside of a string. But what if I wanted to say my last name is well, well, this variable has already set. How am I going to do that? I could theoretically, Right? Caleb Tallinn. And it'll say Hi. My name is Caleb telling, just as expected. But then I have to override the variable. And sometimes you don't want to overwrite the variable. Now I could can cat Nate in two different ways. I can say name is equal to name and I can use this does dot in here so this dot means stereo. So this dot right in the middle, that's my period. That's my period symbol. It's saying, Add this 1st 1 with this extra stuff. So now if I save and refresh, nothing changes because it's still contaminating perfectly. Now there is another option. I was going to remove that and we could echo it directly out. We could say Echo name. I'll make the smaller so it fits on one line. Hi, My name is Houston Cat Nation. In the middle of my string, I place my variable inside there. I can can't need another string. Save it. Refresh. Hi, My name is Caleb telling. So that is concatenation. That is as easy as it gets. I mean, that's really all there is to it now. Few other examples you could say Echo name Holly. And so it's Caleb to lean on. By the way, when you're doing this, you don't have to use my name by any means. Use your own name or use the name of your favorite Ah, Pat movie TV show Anything. Really? Eso this will work as well. Um, Up, up, up, up. Let's let's get a little fancier here. So define HR, and this one is going to be horizontal. Tag this one. Echo HR. This is a constant constant. Never changes. Echo concept constant Ever changes echo. My name is so there we go. Now we're integrating. Ah, constant variable concatenation were starting to actually join all of these things that we're learning together. So now if you're asking yourself a question along the lines off Caleb, why would I ever need to use concatenation when your first example actually worked? Perfectly fine. Because I could take this out, save refresh. This line didn't change at all. So why would I even do that? Well, it's because there are two types of quotes in PHP, and this is again I'm going to create a lesson. All about these quotes, but there are single quotes and there are double quotes. So you've got your quotation marks, these double quotes and these magically let you use variables in here. Name is my name. And so we'll see at the bottom. Caleb is my name and one cycle missing. Push this down. So this is more in the center of your screen. And I could also write in a single quote. Name is my name, and this actually displays the variable name, so double quotes let you use the variable inside them, and this one doesn't. So when I want to use, like for example, I'm talking about PHP right now and I want to be able to print this to the page. I could say something along these lines. Name space at that dot in there. Name. There we go. And now that works. So that's the reason why we use the period concatenation. So that's all there is rather simple. Really. Your task for this lesson is to ah cat me So creative variable. Put it as your name. Your favorite. Ah, your favorite pet. Your favorite TV show. Whatever you like, make some sort of sentence use that variable. And can cat need it like this or like this, But not like this. In fact, I'm actually gonna change that one back so that this code is not saved that way. Okay. Or you could do this way. Cool. When she done, I'll see the next video. 25. Quotes vs. Apostrophes: to quote or to apostrophe. And the last lesson we briefly talked about the difference between that. But in this lesson, I want to actually explain a little more in detail about with the quote or what the apostrophe does. So in PHP and Emerson open nametags here in PHP, we can say name is equal to Caleb. You know what I'm bored of using? My name is my cat's name Zephyr, because he's pretty awesome. Ah, yes. I am a programmer with a cat. That stereotype is true. It's riel. So I could say echo name? Um, yeah, I could say I co name or I could say echo name. And this will really just say zephyrs effort. Just like this suffers ever. But if I wanted to put his name into a sentence, my cat is, and he is. It's put color in there. Color is equal to gray. My cat is ever He is great period in there. So that a proper sentence. Okay, cool. That works. But if we use regular quotations, it now displays not only the actual variable name, um, but the variable color as well. And we don't really want to ever for the most part. Um, talk about the variables, as as their names. We want their variable values. And so that's the difference between these two. And what I'm going to do is just fix this up. So the fear ever looking at this code a little later, you'll see the difference. Cool. So that's the difference now, even though we have I Let's turn out toe break. OK, But now what happens if you have a sentence that has a quote in there, for example? Echo? Um, let's think of a quote, Do or do not. There is no try Yoda. Okay, Pretty typical. We know all about this already, but if we wanted to add a quote in here so that it actually looked like a quote this going to cause a problem because now I've got an empty string. I've got no concatenation in here. And over here, I've got it's trying to Can Katyn eight, something like it doesn't understand that this is not ah, constant. It's not a Ferriol. It doesn't know what this is yet and is trying to contaminate it with the rest of the sentence. This is several errors in one. So what do we do? This is called escaping. So when we have quotations on the outside quotations on the inside, as you can see in the title up here, all you do is put a backslash in front of it. Save it and there we go. It works. That backs natural natural. Because all that backsplashes saying this thing right here, it's saying, Render this as normal. Don't think of this as a program in quotation. Think of this as a sentence quotation to display, and likewise, we can do the same thing with a regular quote. So I just selected all of those and I've replaced those with regular quotes or apostrophes and hold on one second. Let's go ahead and copy that in there. So there's some formality. Some formatting rather not formality. Do or do not. There is no try again. Quotations work. Now you can also use the opposites in here. You don't have to stick with the same one so you could use quotations in here and apostrophes on the outside That would work absolutely. And once I can listen to make some room to breathe, your PHP give us unlimited white space, meaning that it doesn't charge us. It doesn't cost us extra toe have white space. So I prefer to have some of it little more open just for legibility purposes. Okay, so this one worked as well. So I've got the apostrophe on the outside and I've got a quote on the inside that works. And the exact opposite of that will work as well. Now, why is this important? Because if we said do or do not try and let's say his efforts at this and as his name, because I'm using the wrong type of quote in here. So now I have to do one of two things I needed to contaminate this. Make this little smaller. You can see it again. I need to Cat needs this. Now. This is starting to look a little bit messy. But if I refresh Issa Zephyr or I'm not do that, I can swap out the apostrophes for quotations. See how long it took me to do that? That kind of sucks having to do that a lot is not fun work, or I can use thes types of quotes inside where I'm escaping them. Remember, that's called escaping Save and networks. So That's the difference between basically your quotations in your apostrophes. Now your task for this lesson is very, very, very simple. Don't worry about all this other stuff that I did. Just do the 1st 2 just right. These two sentences out my cat name that there's not even a thing. It's my cat's name. My cat's name is and then I want you to use this sentence with regular apostrophes and use the other one with regular quotations and notice the difference. Now, the reason we're learning this one is because in the future you're going to stumbling on something like this. Like why? Why is my variable name actually showing up and why is the variable value not showing up? This is why this is the only reason that this will ever happen to you. 26. String Replacement: there are going to be lots of times in your programming future where you need to replace just a part of a string. So, for example, if someone's name, um, has an invalid character in it or if someone leaves a comment but has a swear in it and you want to remove, that's where you can use something called string replace known PHP. We don't type the word S t r I N g string we type esti are generally speaking. So let's go ahead and dive right into this with a real example. I'm gonna make this bit bigger here. Sentence is equal to hello world and echo sentence and it'll say hello world as expected. I'm going to comment this out and I'm gonna do something a little bit different Echo str replace And what is it looking for? Well, this is a function that you have never seen before, So this is a good time to hop on Google, hop on PHP dot net and look at the documentation. So now we know that it's going to be looking for the word to replace what to replace it with where to replace it and the number of times to replace it. I know that off the top of my head so we can do this Repeal. Replace him. Have to make the smaller against this fits on one line. Apologize about this. If that gets little bit hard to see, so string replaced. First argument is we want to replace world, not with the exclamation mark. We want to replace it with Caleb. We want to replace it in the sentence and how many times we want to replace it. That one is an optional parameter. So let's leave it at this. And boom. Hello, Caleb. No, the variable sentence. Hello. World does not say Caleb in it. What we've done is we've successfully replaced this. Now we can go ahead, and we can actually turn this into a sentence as well. A sentence variable. And over doing here is we're overriding the old sentence with a new sentence Info or data? Rather, it's not influence data and voila, that still works. Cool beans. Now, what if we have another sentence in here? Um, did ah echo HR cause I like to be visually different in the example code. Over here. Eso Let's say another one What if we wanted to replace? Hey, let's say let's say we wanted to replace all the letter goes with zeros, so they look sort of similar. But, you know, we just wanna make a little hackery ish. I guess we could say, Ah, the new sentence because we're just gonna overwrite the old one is equal to, um this sentence will have zero zero's and oh, my gosh, it has a few zeros. Something like that. It doesn't have to make sense causes for demonstration purposes only. Now, if I say echo the sentence, refresh this sentence will have zero zero's and oh, my gosh, it has a few zeros. But if we wanted to replace all of these zeros uh, no. Sorry. Not zeros. Those a rose. Um, So if we wanted to place all these owes with zeros, we say, ah, sentence is equal to string. Replace. And now we're looking for What are we replacing? We're replacing all the O's with zeros in the sentence variable. And how many times do we want to do this? Wow. Let's see what happens when we don't set that parameter. They all turned into zeros. And now what happens if we wanted to get the number of replacements. That's the count. We're gonna put this in here as a variable called Count. And let's just split this onto a new line so you can see this a little bit easier. What are we looking for? What are we replacing it with? Where are we were replacing it? And how many times has this been replaced? So we can say, Ah, Echo sentence. Nothing will change. And after it, we will, captain eight. Uh oh. Was replaced with zero. How many times count times? Oh, was replaced with 04 times, one to three. Before there we go notice my concatenation as well. And the fact that I'm using the apostrophes instead of the quotations, I could have used a quotations as well and not had to can cabinet in here. Your task for this lesson is to create a sentence. Hello, world Some gibberish sentence Like what I made and do some sort of string replacement. And then I want you to count the number of times that it was replaced An echo that back to the screen as well. So echo your new sentence. The one with replace stuff and echo the number of times. Ah, something was replaced. And then I wanted to do one more thing. I want you to hop on Google and rather hop on peach pit on it. Or you could google it and type in string. Replace, and I want you to look at the docks for this one. This one tells me that it works with peach before five and seven string replace. Replace all occurences of the search string within the replacement string. It gives us, Ah, little detailed example here, and then let's scroll down gives us our parameters, what to search for what's replaced with where to replace it, the subject and count, which is optional, which we can see up here because it's in this little bracket E section. I didn't like that right in this little bracket E section, and we have examples down here as well. So take a look at the documentation as well. It's always a good idea to look at the docks, replace your sentence, echo account and check this page out on the docks 27. Arrays: Okey dokey. Welcome back. We are going to be talking about a raise now. We've seen a lot of a raise in the past. We've not really formally dived into them. We talked about them in data types, printed them out in print, are and in Varg Dump. But now now is the time to learn what they actually are. So the simplest way that I can think about how to describe an array is it's simply just a list of values. It's a list of strings or floats or INTs or anything like that. Anything we've been working with so far, it is a list of those. So let's go ahead and dive right into this and make it a little bigger or a lot bigger. And let's take a look at our first array. Now it already can be set in two different ways. We have, ah, ABC do 123 something like that and I'm going to use var dump. But if you don't have our dump accessible to you because you're an ex debug ah, use print are and so far Dump Beret. And here we have we've got two strings. ABC and 123 There's also another way to do this. Instead of using these hard brackets, you can use a soft bracket and use the word array. This is literally the exact same thing. So if I was to, you know, let's move this up and I'll copy that below. It's literally the exact same thing. Vier Dump doesn't even know the difference. It's just two different ways of basically in Stan Sheeting or starting an array through this course. You might see me doing both ways. Um, sometimes I prefer just to use the hard brackets like this. And sometimes I like to actually write the word array so that it makes more sense of, Ah, while you're learning, you know exactly what I'm I'm working with here. And it's not like, Oh, what are these hard brackets like? Oh, you know that this is now in array. All right, so I know for that. Let's go ahead and create an array. So we've got an array of names s Let's not call it a ray. Let's call it names. And remember, Petri gives you as much white spaces you want, So feel free to put things onto new lines and I'm gonna put Caleb Nathan. Fan knows and no Thanatos, because that's Nathan and Panels together. And I find that hilarious. 00 actually, speaking of hilarious, you wanna hear a joke? Okay. Yeah, I've got a good joke here. Why did the developer get fired? Because he asked four a raise more, More. All right, So, uh, do of our dump here. We do have our dump of the names, and we will see a regular list. Caleb Nathan Thantos. Nathaniel's. So this is the easiest array that you could possibly work with. And if you want any of these values, if you only ever wanted to show, let's say fan knows we could write echo names. These numbers here, 0123 always starts at zero. But in human terms, zero is always the number one. So is here was First one is second two is third, three is fourth. So in this case, we just want to plug that number in here. So we want Thantos. We echo names Thantos, and that's comment that out. And, uh, it shows us Thantos. So why would we ever use something like this? Why not just have a variable called Thantos is equal to fan knows why not just do that. Well, we could very well do that. But when we start working with a lot of data, we need to be able to loop through things. We'll talk about loops down the road, but essentially we need to be able to store things in a way that we can access later. Now, if we wanted to say for each of these names, we also want to give them the same last name. How would we do that? Well, we could go in here and we could give them all a last name like Tall Lean. Or we could loop through all of these and we could Katyn ate the value so we could say, Caleb, And then we know how to contaminate. Right? We go can Captain eight telling again loops, air coming. It's down the road. So worry about loops too much right now. But what you should know is that storing data in lists or objects or in this case is called an array allows us to group similar information together. So in this case, all the names are together and we can work with all of those all at once down the road instead of having to do one at a time. So if if we had ah, Caleb is equal to Caleb. And then we had Thantos is equal to Thantos, and we also had Nathan is equal to whips. Nathan, we would have to do the exact same thing three times would have to write the exact same code three times to modify any of these. And there's an easier way to do that again. Those air called loops will get to those eventually. Don't worry about learning loops right now if you're unfamiliar with those, but for the time being, you should know that this is an array. Now, this is also a simple array. So I'm just going to put this in here Simple array or, um, simple basic are a like It really doesn't get too much easier than that. So I'm gonna go do echo H R and make some space for us. Teoh see what's going on here and let's go ahead and create another list of names. But this one is going to have names and ages, so I'm gonna create the array a different way and this one is going to have the exact same stuff. And in fact, I'm not actually gonna write that out. I'm gonna copy and paste that because it's literally the exact same thing. And if I come down here and var dump names open this aired out Because if you have error logging turned on this will also tell you like what the air actually is. It'll probably say something like, uh, missing syntax or missing colon. Or it doesn't understand what var dump is. Meaning that the problem is right before it. Anyways, here, Rio. So okay, it's all the same. But now if we said, Oh, you know what? We actually want to correlate the names with people's ages. We can do this. So this is another kind of array. So in here, we're just going to create what's called a fat arrow. So you use the equal sign and of the greater sent the greater than sign, and it creates what looks like a fat arrow. And I'm gonna put 28 26. I don't know how old Thantos is. I don't know, Uh, 80 I know 800. I honestly have no idea. And Nathan knows our made up character are hybrid between Nathan, and tha knows he is going to be 12. Okay, so now we have a value in here, like all the way down here. And in fact, let's line this up. So this makes more sense again. White space. Not a problem. If this makes reading your code easier, by all means do this. And so we've got a list of names on the left and we've got a list of ages down the right. And if we refresh your page, you notice that the array of the top now no longer looks like the array down below. And in fact, what we've done is we've actually replaced the 0123 with Caleb, Nathan Thanatos and Nathan knows. So if we wanted to get the age of Thantos, we could type echo names Faneuil's. So instead of how we did it up here, where it was echo names to Furtado's notice How that's just a number, because this is just a number. And here you can actually see that there's apostrophes in there. We know that if there's apostrophes, it's a string. So we go echo names Thantos and when we echo this out and I'm an uncommon this so we can actually just see what's going on in here. This will say with all certainty in the world, this will say 80 bam! Just like that is as 80. Now, I'm gonna quickly undo that because that is not technically part of the lesson. So here we go. We've got Indurain here that basically points to other information. So all we've done here is we've reset the indices. So the 0123 is now Caleb, Nathan Thantos and the Thanatos. Okay, cool. So now let's look at one more array. That's bump this down. That's not gonna work because that's html inside of PHP and needs to be inside of a string . And let's create what's called a multi dimensional array a multi die mention no array. Now, really, what this means is array inside array for a raisins had a raise plural, possibly depending how many you have. And this gets a little bit hard to wrap your head around at first, but it gets pretty cool. Uh, once we start dealing with larger data sets because you can now associate a ton of information with Caleb. Nathan Thantos. Jonathan knows. Let's do this. We've got names. In fact, I'm gonna just copy Lis because I'm being lazy. And instead of you know what this is. This is actually gonna look better if I use a ray instead of the hard brackets. And instead of just having a name in here, what I can do is I can say this is another array. So this is like inception for a raise. And in here, we can say age is equal to 28. Height is equal to 1.83 meters, and we'll put a comment in their meters. That's smaller. What else do we need to know about me? Um, profession like job. Okay, programmer. How many friends do I have? Friends? I have. Let's everybody 40 friends. Okay? I'm gonna realign these again. You don't have to rely on these. I just do this so it makes your array a little easier to read. And now we can see that we've got a rain here called Caleb. And when we dump these names down here, we can see near the bottom, right? We've got an array. It's got a bunch. People in it. We've gone array for Caleb as well. Now, I've also have the age, height, job and friends number. And you can see that these air ins floats, strings, whatever you want them to be. And in fact, the Caleb, this Caleb Index here is pointing to another array. So again, this is sort of a little bit of a mind blowing concept at first. And I remember when I was first learning because I was like, Wow, why would I ever need to use these? But the real power comes from this. So if I wanted to get Caleb's height, I could say none of that because I keep making so many typos names I could go into. Caleb. That's my index here. We know that that's going to, uh, basically allow access to this array. And if I want to say the height, I simply go height and let's do this echo. Caleb's height is Caleb site is 1.3. We don't know what that is, but likely have got some comments in here that tells me that it's meters them. Caleb's height is 1.3 meters. Okay, what if we wanted Caleb's job killed job is, and we'll get rid of the meters because that's irrelevant. Killed Job Is programmer Caleb's age. No, I did that wrong, Caleb and age. Caleb's age is 28 and now you see, we can do us with everybody else in here as well. And now, instead of having to write something along the lines of, uh, let's say Caleb is equal to Caleb. And Caleb's age is equal to 28 and Caleb's friends is equal to 40. And instead of going over and over and over again, because we're gonna have to do this for Nathan as well, right? Nathan is equal to Nathan. Nathan's friends is equal to 40 Nathan's, and I'm purposely writing this out the long way so you can see how painful this congee Nathan's age is equal to 26. So now all of a sudden we have six variables, two of which we have to remember, and Nathan may eventually change in the future. In fact, we might even want to unset him. We might want to remove him from this list entirely. And how do we do that? If we have three variables, we'd have to unset each one individually or or here, I'll show you what we can do here, and I'll just reset this so that you can see in here. That's got Caleb, Nathan Thantos and Nathan knows at the very bottom, right? And we can unsaid this unset names Nathan and look at that. He's gone. So we've got Nathaniel's with the Thantos with Caleb, but Nathan is no longer in here, and all of this code is irrelevant. So now we didn't have to unset Nathan's agents, friends or, if we added more properties to him, more details about his life. We don't have to worry about having to unset every single one or finding all of them. We can write one command that does it all for us, and this is just the beginning of us. So now you're working with larger amounts of information that is nicely organized. So there you have it. These are a raise now, Unfortunately, until you learn about loops, honestly, a raise or not that useful, they look cool. It's it's a good way to store data. It's a good way to organize your data board honestly, until you know about loops. They don't do anything. They're just lists. You can't do anything with lists yet, except print emote with other print are or Vardy Bug on by Vardy Bug. I meant X'd bugs module called Var Dump, But again, I'm just setting you up for success right now. These will become a lot more prominent in the future, especially when we're dealing with loops and we'll talk about all that stuff in the future in in their own individual lessons as well. So your task for this lesson is very, very simple. I don't want you to do anything complicated yet. I mean, if you want to, by all means, Go for it. I would never say no to you going a little bit above and beyond. But what I would like you to do is create an array. Call it names, put a bunch of names in their var dump. The names or print are the names, and then I want you to echo the 3rd 1 in the list. So remember the indices started zero, but human start counting at one. So 123 But the indices don't start there. The industry started 012 so go ahead and print that third name from your array. And once you're done that, we're gonna head on over to the next lesson. We're gonna learn something else. And don't forget if at any point you get stuck, feel free to ask questions in the Facebook group. This is exactly what the group is for. The group is made for support. With thousands of developers in there. We can answer all these questions for you very, very quickly. All right. Thanks for bearing with me through this lesson, and I'll see you in that next one. 28. Sorting Arrays: all right, And that last lesson. We talked all about a raise, and I made that terrible joke about a raise and and we referenced Thantos a lot because apparently this is like Marvel sponsored. It's not. I wish it was, but it's not. And in this lesson, we're going to learn how to sort arrays now. At the end of the last lesson, I said, a razor cool is a great way to organize your data and Yadi yada yada, but it's useless for you right now. And honestly, this lesson should be coming a little bit later. But I think because it's also very deeply integrated with the Rays, we should learn about this right now and in the future. You can reference us a little bit later if you need to. So this lesson might be one of those ones that you just watch. You sit back, relax, watch. You don't necessarily need to do the practice of it right now, because the concept is is pretty straightforward. So let's go ahead and create a list of names. A list, as in an array. I write python as well, so a list in Python is the exact same thing as an array in PHP and Javascript. Same name, same story, different name, but the exact same purpose. So I've got a name in here. Have that name Caleb, and I've got name Nathan and I've got name Zephyr, and I've got name Thor. Okay, so if I do this var dump names and remember, if you don't have our dump, you don't need to. If you don't have our dump, you can also use print. Are print are will tell you the exact same thing. You just have to go in there, view your source, and it will show you what we're looking at is a little less detailed. But it's good enough for what we need So far, dump. And we've got Caleb Nathan's effort. Or what if I wanted to sort these in ascending order in alphabetical ascending order, I could do names is equal to are sort, know are sort. That's reverse sort, just sort names. And all I do is pass in the array name. And if you take a look here, So a lot of other functions we've done already, you could do something like this, but this one just returns true this one says it's Boolean. A Boolean is a data type. That means it's either true or it's false. There's no in between. It's either. Yes, no, it's one or zero. It's black and white. It's up and down. It's yes, it's no use talking. It's cold. So that's all this is doing. This isn't doing anything, because now that we have names is true or false. All this is saying is named. The sorting is set into the names variable, and it said that the sorting was done properly. It returned true, So it's OK. We don't want that. So let's delete that. And let's just run this on its own and they're Rio. So now if we go through the alphabet, we've got a B C D e f g h i j k l m N o p Q r, S, t, u, V, W, X, Y and Z or zed and we can see that we've got que en ti said this is now in alphabetical order. Based on the information that is in this array, we can also do the reverse called our sort. Look at that. It's the exact opposite now. But what if we want to have some sort of multi dimensional and not a multi dimensional right and associative array. So when we use the fat arrows were calling this an associative array and we're just gonna put her age is in here. So 28 26 as effort is to and Thor, I I honestly have no idea. You know what? I I just see the number 1000. There's something to go with 1000 save that refresh my page and now you see that are sort. Actually remove this because if we remove that are sort. Look, we've got a regular ray just like what we saw in that last video. But if we try to sort this or are sorted, all it's doing is sorting the values, it these are the keys. So the Caleb Nathan Zephyr and Thor these air called keys or the indexes or indices, and it's not sorting by those. But what if we wanted to sort by those so we could do in a sort? And this one is sorting by the value in here? So this said to is the lowest Thor. Thor has the oldest agent about 1000. And look at that it goes to 26. 28,000. So it's sorted this by its associative values. Now, if we wanted to sort these by the keys in an associative array, we do que sort. And now it's in alphabetical order again. Okay, now, what if we did? Ah, kr sort. So what this one did? Was it sorted alphabetical backwards? And is it a KR? Let's do a are sort and this one sorted by the value but in descending order, so from highest to lowest. Now, if you are uncertain what all of these are, as you probably should be right now, I'm gonna go ahead and I'm gonna put these in here for you to reference later, Sort are sort K sort a sort que are sort. They are sort. And there we go. And I am going to comment most of these out so that you can access these at any point in time. And there we go. We've got some sorting that again doesn't work with an associative array. And your task for this lesson is to actually make this associative array sort properly. You want to see those indexes those keys in here? So it should not say 123 are 0123 Rather, it should say Caleb Nathan's after Thor or in whatever particulary order. And I want you to try out our sort A sort case sort care sort. And they are sort. Now, if you don't know what these are, this is a great time to learn. Open up a new tab in chrome type PHP dot net hit space at all chroma automatically search PHP dot net for you and type in a race sort and you will get all sorts of array functions that's going to air sort And what do we see in here we've got? We've got a sorting flag which we didn't learn about. Maybe that's something that you might want to go and explore. There are examples in here. Um, you can go ahead and read other people's code. Um, really, What I want you to do is you don't have to know these off the top of your head. Um, because in all honestly, they're not used that often to be totally honest, but they are good to know that you have those in your toolbox and at any point in time. You know where to find those on the PHP dot net website. So there you go. That's this entire lesson wrapped up. I think after this, we should move on to something that's not an array because, well, we want to use something as little more useful right now. 29. Conditional Statements: Hello. Okay, you've made a pretty far in this course, and this lesson is pivotal. This is something that is Oh, I don't even know how to explain it. This is the fundamental of programming right here. It all comes down to, if else statements. So in this lesson, we're going to learn about if statements and what an if statement is is. What we see here is it's a conditional and what that really means on a personal level, not on a programmers level, because programmers use weird terms and weird words to describe things. But as a regular person, what this means is, if something is true, if something returns to be positive in a sense, execute some code. For example, if you have milk in the fridge and you have cereal in the in your cupboard or your pantry, make cereal for breakfast. If you do not have gas in your car, go to gas station to fill up tank. If you are thirsty, take a drink. If you are tired, have a nap. That is what an if statement is. We execute them with out thinking all the time in a reigns billions of times a day, most likely, and for the most part, it never ever comes into our conscious brains. It's just something that our brains have been doing for so long that we literally no longer think about it. So let's hop into this. Okay, so I've got some PHP in here and I'm in or say my name. My name. My age is equal to 28. So far, all we've been doing is eco age. Okay, that's cool. That gets us started. That gets us off the ground. We've even put things like this into, Ah, an array and associative Ray ah, multi dimensional associative array. We've done all of that, but that's not useful to us yet because we're not telling a program to do anything with it . All we're saying is, give us a number back and put it back on the page because, frankly, I could write the exact same thing on this page right here. And guess what? It will look the exact same wanna hit refresh, Bam! It looks like nothing happened, and that's because I wrote it in the HTML section versus the PHP section. The browser doesn't know the difference, so we need to create some sort of conditional statement. So let's go ahead and create a conditional statement, and our 1st 1 is going to be just a basic if statement. So it looks like this if some stuff in here is true and if statements always need to return true and there's some tricky logic in here, it takes a little bit of time toe. Get your brain to think in positives and negatives, black and white or what we call them earlier billions. If something is true, you got curly brackets in here. Execute some code. That is it. Don't over complicate that. That is all it is. So we're going to say if age is equal to 28 Echo, you are 20 eight. There we go, and that is as easy as they get. That is really all there is now. We can over complicate this for days and days and days, but we're not going to and good programming. Honestly, it comes down to keeping things as simple as possible. Just because you can make things complicated does not make you a good programmer. It just means that your brain is able to think on a slightly higher level than other people , and you're able to read something that's messier than other people. That's not a bragging right. That's not something employers are looking for. That's not something you're going to get hired for. In fact, that might even be the opposite. That's something that you might get made fun of. People give you a hard time on the Internet because you're writing things that are too complicated. Don't do that. Keep things nice and simple. OK, that is a fundamental lesson from almost 20 years of programming. Keep it simple. That is my experience, that I cannot stress that enough. Keep it simple. All right, So moving on, we have to equal signs. What does this mean? Okay, with one equal sign means age is equal to 28. We're pretty familiar with that. The two equal signs means we're checking to see if the age is, in fact 28 because if we said ages 27 nothing will show up just like that. But if we said the ages 28 just like before, it will show back up, and you will, I promise you, you will make this mistake where you will be writing Ah, conditional statement and you only use the one equal sign. Just what it still happens to me. 20 years later, it's often just a typo and it will hang you up. You will get stuck now In this case, PHP thinks that this is true. But I could also run this as ages equal to 21. And PHP still thinks this is true. Why? Because this value was set to this age properly, it worked. And if I said echo age, it now thinks my age is 21. That's no good. And that's because you basically overrode this age with an age in an if statement. So you're going to run into that every now and then. Just be aware of it. And it's not the end of the world. So just a heads up. You will make that mistake. And it's not the end of the world if if you make that mistake so basic operators here All right, I'm gonna clean this up and let's do this eco hr And let's talk about basic operators. So what you see here is the two equal signs that that's just an operator. That's all that's called as an operator. It means, if it's true, if it's not true, like when I said ages 27 this does not show up because that's false. And just to really drive this home, what we're saying here is you see how it matches up at the top online seven and line nine, where it says Agent age. What the computer thinks is this. If 28 is equal to 27 we know that that's wrong. Even if you're not a super logical thinker right now, your brain is saying, Ooh, that's not right And it won't work because it's false In programming, that's a logical fallacy is called falsehood. So this is a false. And if we just said that back to 28 that's true, because the computer thinks essentially 28 28. Yep, that is true. 28 is 28. There's no other number. 28 can be. It can only ever be itself. That's true. Run some code, all right, moving back onto basic operators. So we have a few different operators in here. We have got the greater then we have got the less than we've got, the greater than or equal to less than or equal to. We have got equal Teoh. Now, don't panic, because these are super easy And I'm gonna fly through these really quick because you will pick up on these just like that, It's gonna be super easy for you. So let's change age here, too. 18 and just so that when you look at this later, it's not wrong if age is greater than or equal to 18. So in my province in Alberta, Canada, the legal drinking age is 18. So I can say you are allowed alcohol. Alcohol? Oh, boy. Sorry. New keyboard not really used to typing on it yet. All right, so my age is equal to or greater than 18. That's true. Is is the age 18? Yes, it is. Is it greater than 18? Well, if I change this age to 20 it still says you're allowed alcohol and the 18 operator disappeared. And the 18 conditional statement, the if your age is equal to 18 disappeared. So let's change it back to 18 and says I'm allowed alcohol. But if I said my age, No, that's wrong. But if I said my age was 17 because you're not allowed to drink alcohol. Your it's at age 17 that goes away. You are not allowed to drink alcohol when you were 17 years old. The legal age is 18. You have to be 18 or older. That's what this is. Think of that as the greater than or equal to that greater than or equal to is you are 18 or older. Alright, changing that back and let's say you are less than 18. Okay, you are less than 18. You cannot vote well. It says I'm 18. Cool. We know that my age is 18. If I'm less than 18 I cannot vote. Nothing showed up. That means it's false. What this is saying is, if 18 is less than 18 we're just false. Excuse him code. Remember, this always has to be true. This has to be true. So let's change that back to age. And let's change my 8th May my age down to 17 says I cannot vote. I can change that, too. Seven. I still cannot vote because it is less than 18. Cool, basic. Right now let's say I wanted Teoh give access to someone onto a certain group of users on my website that ages 45 under. So my age is now 45. I'm at the very tip of that threshold. This is you can be less than or fort. This is you have to be 45 years old or younger, less than or equal to 45. So what this means is 44 is acceptable. 46 is not acceptable. 45 is acceptable and we'll say secret access granted and the real secret access granted. But if I said my age is now 46 because I had a birthday, I don't have that access anymore. And now for the real simple ones, because I actually started off where the hard ones is. If your age is greater than 45 so you are not allowed to be 42 43 44 or 45 you have to be older than 45 secret access granted, okay, because my age is 46. If I said 45 I don't get that anymore, because again, just think about replacing this with that number. If 45 is greater than 45 runs in code, it doesn't work that way. The opposite of that is if 45 is less than 45 secret access would be granted. But again, mathematically, that doesn't make sense. 45 cannot be less than 45. 45 is 45 and so nothing happens. But if I said my age was actually 44 because I lied about it Well, guess what? I now have access to that. Okay, so this this is an if statement and remember, you have your basic operators in here. So what I want you to dio is do exactly what I did in this video. You don't have to fully understand because you were going to write millions of these things in your lifetime as a programmer. But you do need to understand that Ah, to equal signs are not the same as one equal sign. Um, and that you are going to be validating certain things. If your name is equal to Caleb, for example. Right. Let's make this example. My name is Caleb, and I wanted to say if name is equal to Caleb, notice the capital K and both of them. Then I get secret access. Granted, if the name is John, then your secret access is granted but my name is not John, so I don't get that. But here's what I want you to do for your task check of these different operators use basic numbers to begin with, just using age. It's the easiest way to start. And then once you get that down one to understand how these work a little bit, I want you to change it from age and numbers toe a string, so change it from age to name and and check if your name is equal to John or in this case, it's, uh, what sweeps up ups. What am I doing here in this case is Caleb. And what happens? What happens when you use a lower case K? Is that still acceptable? We know that PHP is a loosely written language, so it should probably be acceptable, right? If there is a capital K in a lower case K or whatever letters you want to use, I want you to go and explore that option explored by yourself. The best way to learn is by doing get your hands dirty, figure it out, struggle a little bit, but not too much. And if you really get stuck, ask questions in the Facebook group. There you go. You know, know the number one thing that rules the entire world. If statements in the next lesson, we're going to learn about else statements, which is the exact opposite. So if something is false, what do we dio? 30. Else Statements: Hello. Welcome back. In the last lesson, we talked a boat. If statements we learned a boat, if statements and condition ALS and greater than and less than a greater than or equal to or less than and equal to the two equal signs at all that stuff. But what happens if we want to excuse him code when something is false? Now, remember, if this section in here world his daughter is true, it will execute the code in here. But if we want to execute something that isn't true in any other situation, we can write some code in here, and this is this intact. We write else, and it just attach is right onto this last curly bracket. Here, Ellis opening curly bracket, Your code closing curly bracket. Literally. That's it. Now, if you wanted to, you could theoretically turn the video off right now. And you are good to go. But if you're not comfortable with that, let's learn about this so age again. We're just using a very, very simple, simple conditional here. Okay, if age is equal to 18 um, actually, let's not do 18 because that seems limiting for, uh, examples. Ages 18 or older than you can vote, you can vote. You can also be drafted. You know, if you live in a country that supports drafting, All right, So if your age is greater than 18 echo, you can vote. But what if your age is not greater than or equal to 18? What if your age is less than 18? You are a child, maybe not a child that seems sort of offensive, but you are definitely you are young still. Now when we run this, this is going to say you can vote. Why? Because age is greater than or equal to 18 again. This is equal to, ah, the computer, thinking that 18 is greater than or equal to 18. It's not greater than, but it is equal to 18. Let's undo that. And let's change that age, too. 12. Okay, so my ages 12 now, And when I refresh this page, it's not going to say I can vote because that's inaccurate Again. If we just replaced this with 12 is 12 greater than or equal to 18? No, absolutely not. It's it can't ever be anything other than 12. So if if we're avoiding age, say we can vote otherwise say we're still young and boom! It says we're still young. It doesn't care if the ages 123456789 10 11 12 13 14 15 16 or 17. All the or any negative numbers all it cares about is that it is less than 18. Now, this is the equivalent of saying if your age is less than 18 echo you whips, you are still young. You are young still, you were still young. There we go. They both show up because this one was true. Your age is less than 18. It executed this. This one was not true. Your age is not greater than 18. It did not execute this. What it did was it said ok, that's not right. Execute this other block of code in here. And so now we're dealing with a false ID. So this one false. But this one is true and this one is the opposite of true a que false. Now that's all there is to an else statement. In the next lesson, we're going to learn about else if statements which basically lets us right more of these and If nothing is met, then we can run an else statement. But just so you know, the else statement is completely optional. You do not need it. It is not required for an if statement to work. All you need is the if statement. So your task for this lesson is to create an if else statement. Keep it simple. Remember, don't make it complicated. Don't confuse yourself. Don't get overwhelmed. There's a lot of time to learn this. And again, you're going to be writing so many of these in the future. That this is just going to become a second sort of nature for you is going to become very, very easy. So don't worry about mastering this part right now. So your task create an if statement and then create an else statement. And I want that l statement code to actually execute the if statement should be ignored. But the else statement should execute. Once you've done that, let's head on over to the next lesson. We'll talk about else if statements 31. Else If Statements: all right in the last two lessons we talked about, if statements and else statements. But there's one more in between, and that's the else if statement. So right now, we know that I'm just gonna reek. Recreate this example. We've done the last two episodes. If my age is equal to, let's say, 21 Echo, Um, I don't know B'Day party in Vegas. Okay, else my age is not 21. My age is anything other than 21. It's 22 or higher or its 20 or less echo. Do anything else. And here we go. It says, Do anything else because my age is 21. Sorry, my age is 18 but it's checking to see if the ages 21 now there's one that we can add in the middle here called else ifs and this else if it's literally else. If and actually wow, that's pretty cool. Sublime. Just fill that in for me when I hit. Enter so else if and here's my condition else. If age is equal to 18 and my code is going to be echo, I am 18. Let's go snowboarding or something along those lines, and let's just clean that up, Put those back on the same line. And here we see it says I am 18. Let's go snowboarding. And if I flip this back to 21 B'Day party in Las Vegas now, we can have as many of these as we want. Now, keep in mind that these are all going to check for the same thing, so it's pretty pointless. But if we said 19 and then 20 and then this one would be 22 let's say this one was 17 and I'm just gonna it's like all of these echo and all I'm gonna do is put the age in here age 1920 22 and 17 and this is gonna be some other age. Now look at this V Day party in Las Vegas because my age is 21. But if I said my age is now 18 it says 18 and I say 19 it's 19 is going to keep going through if I co down into my age is 20 hoops drag and drop. If I say my age is equal to 22 guess what is going to say 22 because I said that because I said check if 22 just like that. 22 because I said check if 22 And if I said my age was 1000 years old, it's a some other age. Or if I did a really, really small number, let's do minus 1000 some other age, so you can see that we have unlimited else. If possibilities here. No, it's always going to execute from the top to the bottom. If this one is true, excuse this code. The stuff in here online 10 and ignore everything else. If that doesn't work, is going to check the next line. If the ages 18 execute this code and ignore everything else. And it's going to do that until it gets to the else statement where it says if the age of 17 well, it's not so. It's not going to execute this code. And if it is anything else, anything else that does not match any of the requirements between line nine and 19 or however many elf else. If statements that you create it does not matter, it will execute some other code. And again, the else statement is completely optional. So if you are some other age. You were not 2118 1920 22 or 17 because I put that in a weird order. For some reason, it won't do anything. So now you can execute certain bits of code based on certain bits of information. And if some requirement is not met, you can either take action or not take action because that's exactly how life works. Something happens to you. You're able to either do something or not do something. I mean, it really just comes down to that. So what I'm going to do here is just creates a more advanced example so you can see what I'm going to be doing in the future again. This part is like, you don't have to worry about this next part. Just this lesson. Focus on the else F, but I want to show you something cool to help keep you engaged to help show you how dynamic PHP can actually be. So I'm going to use what's called a super global variable on which change that to set that as name get name and if name is equal to Caleb Echo. Whoops. Hello, Caleb. I was in the tech world else if name is equal to Is that for Echo my kitty Else? If name is equal to hunk, we are going to say Echo smash. And if you were nobody else, grips should be lower case echo. It will be a little more professional. Be like welcome, guests. Okay, so you're gonna see that. Welcome. Guesses What shows up. Now, this is the part that you don't have to worry about right now. Is what is this? Get parameter. We're gonna talk about this later. Again. I'm just using this as an example to keep you interested. So I say name is equal to Caleb. Hello, Caleb. My name is now equal to Zephyr. My kitty, uh, name is equal to Hulk. Smash. Right. So now we're changing all of these parameters based on the U R l The U R l is actually changing every time I add something else in here. This is actually reloading the entire page. And what is doing is it's saying, Oh, if there is a parameter in the u. L called name and it matches Caleb, say hello, Caleb, If it matches, ever say my kid, if it matches hulks a smash. And if it's anyone else, they welcome guest. And so now you're not just hard coding anything. You were actually letting people change things based on the U. R L So there you have it. You now understand if statements l statements and else if statements and there's another one that actually sums all of us up really easily, it's called a switch statement. Um, and we'll talk about that one in some other lesson. But for now, what I would like you to do for your task is create an if statement an else if statement one or more else, if statement. So you've got two of them in there and create an else statement. No. Remember that all of these air optional, including the else statement and all you really need to do is validate one thing. If any one of these matches, it will execute that block of code and ignore everything else. So there you go. You have a little bit of homework, tinker around with that, have some fun with it, possibly play with different operators as well different conditional operators, so that is greater than or equal to. That's less than or equal to is greater than is less than there are a couple more that we're gonna talk about in ah, conditional lesson. That's all about more advanced condition ALS and sort of how we get some more advanced logic in here. But for now, this is all you need to do. So go have fun with that. Feel free to tinker around with us, get parameter as well. And once you were done with all of this, head on over to the next lesson and I'll meet you over there. 32. Comparison Operators: Hello. Welcome back. First I want to start off with a joke. If Harrison Ford was a programmer, we would probably call him compares. And Ford want, want Want? Uh, okay. Comparison operators we actually know about already. Remember, in last several episodes or lessons, we said if age is equal to something, something, something. Right. This here is your comparison operator. Well, actually, this is called your conditional statement. And this is your comparison, operator. Is it equal to Is a greater then is that less than is a greater than or equal to? And we said, Okay, if the age is greater than or equal to 18 do something. Otherwise, you are still a child. You are still, kiddo. Cool. So we know all about that stuff now. But there are some other ways we can do things to. Because what happens if we want to check? If someone's age is less than 18 now, there's something else we can do. Let's say we want to check to see if someone's age was 18. Okay, you are 18 years old. All right. Simple enough. But what if we want to check to see if someone's age was not 18. Literally. Anything else we would have to say if age is equal to you 18 but nothing in here and just execute everything in an else statement. So essentially, what that would look like is this. I don't even know how to do this because they look so weird. Okay, let's Ah, I get Yeah, I don't know. I guess something like this. Anyways, we don't do that in programming. The reason for that is because this is far too much code. And if you ever thinking Wow, this is actually not that much code. It's only a few characters of typing. Don't be so lazy, Caleb. Well, guess what. Here's a secret. Programmers write reusable code because ultimately we are lazy. We do not want to do more typing than we have to. And this has been a programming sort of concept of fallacy. Oh, rule that we have been doing for well since the first programming language came out decades and decades and decades ago. So what if we said we want to get someone's age who is not 18 while we need a different comparison operator for this one we need is not 18. So I'm gonna go ahead, scrap this real quick. And now I'm going to say age is equal to 18. Okay. I wish I was still 18. Would never nice. And and now I want to say, if my age is not 18 do something. So in this case, we're not going to type. If age is equal to 18 ignore this else. Do something in here. We're not going to do that. That's gross. And also, that's no way to live your life. So what? You saw me just right there is the not operator. This is not equal to 18. So that's just take a look at this. So equals means is equal to, and this one means is not equal to And in fact, those should not be in the bottom should be up here. If age is not equal. Dio you are not 18 and in fact nothing shows up because this is actually false. That's this is what the computer is looking at. The computer that is executing this code right now is saying, if 18 is not 18 execute some code. Ah, but in fact 18 is 18 year because 18 can only ever be one number that can only ever be itself. This is false. This is where the ah, the true and false logic. It gets a little bit tricky at first. Once, once you start learning about this kind of logic, okay, age is not equal dating. So what I'm gonna do is understand to go through a bunch of examples here, and I am going to kill this thing, and I'm just gonna drill it into your head. And once you've got it, you could probably just turn the video often. Go over to the next one if you want to. But if you don't necessarily understand all of it or you feel like you want, um, a better understanding feel free to hang around for a couple more minutes. Okay, So I refresh the page and says, You're not 18 because my age is now 20 and in the opposite, I could say you are 18. Nope, that's 1918. That's 1 81 and still says you were not 18. That is okay. In fact, that's actually what we want. Your age is not 18. If we said your age is 18 well, this will give us the wrong answer because this should actually say you are in fact 18. See, you are not 18 but in fact you are 18. So here's where it gets blurry. Because I changed one number. And now the text that is being output to my browser is backwards. So I'm gonna refresh this so it comes back to normal. Says you are 18 and let's undo this one. So it's checking to see if I am not 18. You are not 18. Cool. Okay, so let's check another one. Let's let's do a name. Let's do Caleb. If name does not equal Caleb Echo, you are not the teacher. It doesn't show up. Why? Because I'm the teacher. But what if my name was not killed? Would what if my name was Iron Man? Is it? Is it two words? Is that Iron Man or is it Iron Man? I don't know. Ok, so my name is now Iron Man. And it is saying if your name is not Caleb, guess what? You're not the teacher, and here it is. You are not the teacher because your name is not Caleb. The only person that could be killed the only the one condition that will execute this code is using the not operator, the opposite operator. It is using the not equal to operator. Now we've already learned about a bunch of other ones, so we know about greater than less than and greater than equal to less than or equal to equal to not equal Teoh. And there's one more. And this one is very, very tricky. And this is where you need to know your data types. So let's do this. Data types are important now, granted, they are less important in PHP, but and pretty much every other language in the world, they are wildly important. And if you want more efficient code, if you want something to be faster even in your JavaScript, you're gonna want to use this bad boy. Three equal signs. It means not only is the equal to, but it is the same data type. Now let's let's take a look at this. I'm gonna create a bunch of room here so that we can see what we're working with. And I'm gonna split this up with a horizontal rule because I like doing that visually and this next section here. Ah, let's put this as Baba Baba. What should we do? Number of books. How many books do you have? OK, you have got three books. If books is equal to three Echo, you have three books. Remember, this is using Think of this as a soft comparison, so it's not only checking to see if this is three, but this will also match. And let's do it else. If else if books is equal to three Echo books, is three and let's put this in here into Let's put this one in here string and else echo something else just as sort of a catch. All right now on that failed. Here we go. Put that back in there. There we go. It says You have three books. It's a string. Well, that's because remember, PHP is a loosely written language. So three ah, with quotations around, it is technically a string, but also matches three. And so when you refresh the page, nothing changes. But let's talk about a strict comparison. A strict comparison is checking not only the value, so the value has to be three, but the data type has to be the same. So the data type of books has to match the data type of this. Now we know that this is a string and this is an int. So this is the exact same as saying Ah, if and is equal to string executes encoding here. That's essentially what this is saying. So this will no longer run. And when I refresh, the page says Books is equal to three, and now that's because this match is now. This is also a soft comparison. If we wanted to do a strict comparison, this will still follow through, and I'm refreshing the page. You might be able to hear me just slamming on that command are there and refreshingly crazy and nothing is changing. And that's because this is saying, essentially, let's do this. Ah, create a comment here just so we can sort of see ah, the difference Bear with me While I learned how to use my keyboard, this is saying if books, which is an end, is equal to three, which is also an end, an integer then execute this code. Know what this is also saying is if three is equal to three, it's also checking to see if three is not equal to three. It's doing all of these things. So the three equal signs have to be a perfect match now in PHP. A lot of the times you're not going to see this triple equal signs the strict comparison. Too often it's It's a lot more rare than you think in PHP, but it is making huge strides in last couple of years. A lot of people are starting to use it. And with the accelerated growth of JavaScript, which uses the strict comparison quite a bit, you will see yourself using the strict comparison more and more as as the years go on. So I'm just gonna do some of this stuff because that's making the code real ugly. And so here is the difference between district and not strict. Now, if you didn't fully understand that, what I would suggest for you to do is to write this code out manually. Don't copy and pasted, don't grab the source code in and just try to edit my code. I want you to write it opened manually because there's something about getting your hands dirty and getting in there and just trying to figure something out on your own. That sort of makes it clicking your brand. Mexico. Oh, I get it now. Now, if you are still confused about all of this, please go back to the comparison lesson. I guess this is a comparison. Listen, go back to the lesson on Ah, where was it? Uh, if statements we talked about, um conditional Greater than less than equal to. We talked about those in the if statements lesson. And if you still don't understand the difference between the ah strict comparison and the I call it soft comparison but the less strict comparison where there's only two equal signs um, go back to the data types lesson. That's, ah lesson. I've got as 1 30 here. So less than 13 ish, depending on which platform your, uh you're learning depending on what platform you're taking this course on. Ah, but there we have it in here as well. We've got inst floats. Ah, well, that stuff is in here for you. So go ahead. Give that a shot. You don't have to master this one either. You don't have to be Ah, professional or an expert. You don't have to be able to have full conversations about this yet because in the future is going to be writing so many of these that it's just going to be second nature for you. So go ahead, Give some of this a shot, check it out. Definitely learned the is not equal to this part is vital. You need to know this one the is not equal to is very, very important. And just as a reminder, why does this work? Because name is not Caleb. It's the same thing, right? This is true. The statement is true because Iron Man is not equal to Caleb because, um, in here 20 is not equal to 18. These are true. It's sort of like a backwards logic here, but it's not really backwards in the sense that sort of just in versed in the sense that this statement always has to be true. So I'm gonna undo those, um, and again, yet your task. Just get some hands on experience with that is not equal to operator. Um, and maybe try to play around with the strict comparison. And if you don't get it reference other lessons, and if you still don't get it, you know what? That's okay? Because eventually you will get it. It'll just click for you. Alright, that's enough of this lesson I'll see in the next one. 33. Incremental and Decremental Operators: Hello. Welcome back. This is going to be a very quick lesson. Ah, this is something we probably should have learned, Uh, quite a while ago. But you know it. Better late than never, I guess, eh? So in this lesson, we're going to learn how to increment and deck Crimmins by one. And it's actually super super easy. And you know what? You're honestly going to use this a lot more than you think you would possibly use us. So let's say my age is 20. And if my age is also equal to 20 execute some code in here, execute this code, and I want to say you know what? Let's let's let's make this a little more complicated. Another bonus. Let's do points is equal to let's say, I've got 75 points and my age is 20. So for whatever reason, just being the age of 20 gets me one extra point. I could do points plus plus. And so let's do this. Let's go echo points. The number of points that you currently have are points, and let's add a line break in there just so that the smell doesn't look terrible. You now have points. There we go. And when to refresh the page, take a second. And just think about this. What? The point is going to be okay. We said plus, Plus, we know that this lesson is about implementing and Decker Menting. So I mean, even tells you in the subtitle right here. When you refresh the page that will say, 76 Boom. Just like that 760.75 unit have 76 and that's all this does. And you can keep doing this over and over and over and over again. I'm going to copy a bunch of and I honestly have no idea how many have put in here. I just hit copy and paste a bunch. I now have 89 points, so I'm gonna go and delete that and let's say for any given reason, we just need to decrease the number of points by five so we could do points is equal to points minus five. If we wanted to do it that way, or we can do points minus minus and do that five times now, I prefer this way personally because it's just a lot cleaner, but you can also do it This way, so I'll show you both. Okay, now I have 71 points because I went from 75 76 75 74 73 72. I now have 71 points, and that's what is displayed on the page. But if I comment that out and use the first way, it also works. Now let's comment that out and let's try one other way. Points is equal to minus. Nope. Minuses equal to five. This also works. Okay, so watch us. I'll common this out. I have 76 points and this one is saying points. Basically, it's shorthand for this. It's saying points minus is equal to five. So whatever it currently is minus five. Refresh the page and it's 71 I could do the exact opposite with the plus sign as well. Plus is equal to, and it's just shorthand for this. That's all it is. So your task for this lesson is to write an age or some sort of number, I guess. And remember, this really is only going to work with numbers because Onley numbers or floats can increments or document by one. So right a number variable increment it by one using plus plus deck, prevented by one using minus minus. And really, that's all you need to know for this lesson. Once you've done that, let's quickly skip on over to the next video because this one was honestly not as fun as programming can be. 34. Not True: Hello. Hello. Okay, so we quickly learned about incremental Zand Detrimental Z. But let's quickly hot back to condition ALS. So there's another one that we should learn about. And I actually realize that we haven't really been using Boolean that often. And Boolean is a fantastic actually Tate a type because it's so simple. Boolean can never only be true or false, So let's say we have Oh, what could be true or false? K Ah, the sky is blue so it's a blue sky is equal to capital t Is python eso lower case? True, We could also say it's false if the I don't know if this guy is gray if it's a rainy day But let's stick with true great And we said, If blue sky echo today is nice outside and we echo list of the page, you notice how there is no conditional in here. This is not saying if Blue Sky is greater than one, or if blue skies equal to true. Although this will work as well. In fact, the strict comparison will also work. Um, and maybe just as an experiment, let's do this. What happens if Blue Sky? Because this is a Boolean. This is a different data types in the string. If we did a soft comparison to the word true also turns out okay, but just to blow your mind here, What if we wrote false? It still works. If you are interested in learning more about that, feel free to ask in the Facebook group. And I would be more than happy to explain, um, otherwise you can hop on the old Google machine and, you know, do a little bit of Googling. It's also a good way to learn, do some research on your own time. Not that I'm trying to be lazy or anything. It's just, you know, I'm trying to prep you for the future because once you get out there, once you're done this course you're going to be doing a lot of research on your own as well . So we did not need any conditional in here because this is true. Remember, if statements always have to be true if that condition is met, if this is true, it's just the exact same is saying True, This will still say today is nice outside. But if we said if this is false, it won't say anything because false is not true. Now we can also do the exact exact same thing using the number one or the number zero. So we can say Blue sky zero. Nothing's gonna show up because this is the equivalent of false. Or we can say one which is the equivalent of true. There we go. And in fact, any number that's higher than zero is considered true. So we could do something like this also considered true. But what if we did like minus 12? Also true, Because it's not 00 is false. Everything else is true. Great, false, but for purpose of keeping this code so you can access it later on. Get hub. Keep it as ah, this. And in fact, just because I want you to be familiar with brilliance because billions air so powerful if you can boil everything down to a Boolean, your logic becomes so much easier to understand. All right, so these are the same thing now. What if we did something opposite? What if we said this guy is not blue? What we could say? If the sky is equal to false right, nothing's gonna happen in fact, let's change this. Let's change us too. This guy is not blue. There we go. Nothing happens because this is still set to true. If we said this is false now we're getting into some weird territory where false is equal to false cause. That's what this is. So what we're saying here is zero is equal to false is equal to false. All of that is the same thing. It's like in school. When you learn that 1/1 is the same as one is the same as 100% is the same as 1.0. It's the exact same thing. We're just We're changing the measurement in a sense, so we say blue sky is equal to false cool. That works, but there's a faster way. There's a better way you don't have to say is equal to false, because the shortcut for that is this exclamation mark. Exclamation mark right here says, Is this the opposite? And so what we're saying here is the opposite of this. In fact, let's actually changes back to true. So remember originally, if this is true, the sky is blue. This guy is blue else. Echo the sky is gray Refresh. The page says the sky is blue because that's true if we wanted to check to see if this guy was not blue All right. Ah, we could change that to false This guy is gray. Or if we wanted to change this to B blue still right, because at this point and again, it's really, really hard to explain. This is one of those things that you really need to understand. You need to, uh, work with it a lot. You need to pound it into your own brain into your gray matter so that you understand this . And again, this is much better if you do it on your own. Don't coffee this code. You know, good practices to write this out, to play with it, to mess with it until it messes with your head until you go. Actually, you know what? This makes sense. Okay, I'm done rambling, I promise. No, I don't promise. I'll probably ramble some more eso were saying, If this guy's not blue right, that's what does it means. So you can actually read this like a sentence. So this says if not blue Sky Code stuff here That's what this is saying. If the sky is not blue, if sky not blue, if not blue sky, right? Sort of the same thing. I mean, it's terrible, terrible English, and the grammar is impeccably bad. But it still makes sense, somehow to your brain to make sense. So we say the sky is not blue. This is actually going to spit out the wrong text, which is correct. This guy is not blue and the sky is blue. And so now all we've done is changed these lines. And in fact, I want to show you essentially what this does all right. As an example, the sky is blue. Let's let's keep this simple. The skies. But you're looking outside. It's beautiful out. There are no clouds. It's just a nice blue sky. Okay, when we refresh this page, it says the sky is blue. It's because it's true. It's nice out. It's beautiful middle of summer. Perhaps Now, if you want to check to see if this guy is gray, you would add this not and we will just reverse where these lines were. So I just switched them, That's all I didn't refresh and it still says the sky is blue. That's because it's checking for the negative. It's checking for the not it's checking for the false first. So if we change this one now the sky is gray. Why? Because we said is this guy blue? It is not blue, is it not? Not blue, because this is the equivalent of saying, Is this guy not not blue? Now, I know this is terrible English because you're never supposed to use a double negative like this. But you can essentially say these will cancel each other out is the sky blue. And that's what this is asking. Because is this guy not not Blue is the Sky blue is the same thing. This guy is currently not blue. So this guy is going to be gray. All right. I have said way too much for this lesson. Um, you will see these not symbols all over the place. These things here, you're going to see them. Ah, lot. And all we're really saying is is something true or false, or is it the opposite of true? Or is it the opposite of false like, What kind of answer are we looking for here and the general reason why we would use that is so that we don't need an else statement at all. We can say if the sky is not blue, do something else or if the sky is blue, do something. So there's no task for this lesson because our I've already talked to your ear off on this one. Uh, um, about something that is already sort of confusing if you want to, uh, play with us a little bit, right some of your own code and just test it out. But generally there's no task for this one. And you might see this in the future a little bit. I'll try to ah, to remember, as I'm recording these lessons, um, Teoh explain things like this just because we're going to see these more and more. And I don't want anyone feeling left out or confused or feeling like we didn't learn this already. 35. Ternary Logic: all right. Up until now, we've learned about true false, if else statements else. If statements all that good stuff, which is actually all very, very, very important in computer programming now. The reason that's important is because when you give a command to ah, program or a script, you're saying if something is true, executes some additional code. So if someone likes your post, send a notification. That's sort of the logic one that's not sort of that is the logic behind all programming, really. But there is a shortcut, and this one might be a little bit mind blowing and might be a little bit hard to grasp it first, So don't feel the need to master this right away. Continue writing if else statements a long way. But here's what turn Eri Logic looks like. Turn Eri logic is basically, if something is true, set a value. Otherwise it's not true. And really, what we're looking at here is name or let's do something easier. Age age is equal to 30 and then we could say is allowed to actually do it. Let's do lets you 18 and let's change us too. Can counts, can drink is equal to And we could set this to true Or we could set this to false, but we don't really know yet. And what is that? What is the determining factor here? It's your age. So we can say if your age is equal to or greater than 18. True, otherwise false. Now, if this looks complicated, it's because it kind of is. And so what I like to do is rap some brackets around here just to make this look a little nicer so that we know that this can drink. This can drink alcohol, variable. What it is doing, it is assigning a value of whatever this is. Now, if you remember back in high school there was the order of operations. It was bed, miss um, or something along these lines of algebra where you had you did your brackets first, then your exponents, exponents and then ah, division or multiplication, which everyone came first. Yikes! I cannot spell it all. Ah, and then you had your addition and your subtraction. Whichever one's came first. And in the very front of that we see brackets, and so that's sort of the logic here. You don't necessarily need your brackets, But this is the way I said it out because it looks a little nicer. And so this is your if else statement If this is true question mark set the value to true. If it's false or what you're else statement would be set this to false. And now we can say, if can drink echo you, um we're going to hear Yeah, you can drink. There we go. You can drink. But if I change this value to and let's just let's use a detriment a detrimental operator to lower that value by one. So now this is actually 17. You cannot drink because that value is false. And let's take a look at this var dump can drink. Can three Yunque there. I'm gonna roll today with, like, not being able to type anything. So there you have it. Line 15 on index dot PHP is a Boolean. Look at that. We've said billions and it is currently false. What if What if we just comment this whole thing out and my age goes back to being 18? Look, you can drink. What if I var dumped both age and can drink now we can see. Look at this online 15. We've an integer 18. Boolean is true uncommon. It's that Decker mentor and Fabio. Look at that age is 17 can no longer drink. But you know what? Let's let's make this more advanced. Let's say your age is going to be We're gonna typecast this. Get age now you don't know what get is yet. Technically, you might have an idea because we've already worked with us a little bit. Um, and again, I'm just using this toe kind of show you how dynamic PHP can be. But if I said the age with 17 it'll tell me my age of 17. If I tell you that my age is, um 819,000 that opened up the wrong window. Now if I told you that my age was 819,000 the Rio integer 819,000 Boolean is true. And what if we did not type cast this. Let's just show you what typecasting really does. See how this is an integer right here. It's now a string. Although PHP is loosely written so it understands at the string can also be understood as a number and so it still comes back is true. So let's typecast that. And, um, in a throw this into some notes here, some documentation. So that's really all there is to turn Eri logic. It's a shorthand method for if else statements it does not really handle else. If statements, it's really just Are we breaking something down to true or false? Can it be easily broken down and easily understood? Now I see a lot of people a lot of new PHP Debs will be like, Oh, this is so cool. Let me write another one inside of another one. Let's make this overly complicated. Remember a few lessons ago where I was saying Don't make things overly complicated. I'm not kidding. Don't do this. And this is why some my name is equal to Caleb. And I'm gonna move us on to a new line, make a smaller Seacon see it, and I'm gonna add another turn. Eri operator in here. Okay. My turn, Mary Operator is Name is equal to Caleb. Ah yeah. Lets that killed urinary operator. If my name is equal to Caleb, I'm going to return true. Otherwise I'm going to return false because even smaller. So it all fits on one line, and I apologize if you can't see that very well. I don't usually like to make my lines of small so that after zoom out. But what this is saying here is if my age is greater than 18 it also wants to check another turn Eri operator. Now, if my name is Caleb and my age is older than 18 is going to be true. Otherwise is going to be false. And if my age is less than 18 is going to be false. So let's go ahead and refresh the page. And let's change that age to 18 and we get false. So you might be thinking, Why? Why is it false? Because my name is Caleb. It's Caleb. My age is over 18 or it's equal to or over then 18. Ah, it should not be false. Everything should be true. Well, this is the complication behind using multiple turn Aires and with all due respect and And I'm saying this not only as your teacher but as a PHP developer and your peer as a colleague. Don't write these don't write turn areas inside of turn, Aires This is terrible, terrible logic. Now, the problem here is the capital. Okay, that's all it was. But now what happens if we add another one? Right. And what happens if I have a strict rule that my agency to only ever have, like 7 79 characters per line or 80 characters per line? Right. So now we have to come back up here, and I'm going to do this. And so this already looks terrible, actually. Know what? Let's make this look nicer. Just bear with me while I just sizes and stuff. So if your age is over 18 this is your true statement. This is your false statement. We get at another veterinary logic in here and like, this isn't making much sense, is it? Now, you should understand what this means, but it should also take you a few seconds to actually digest this Because this honestly is okay, code. But it is becoming too complicated, right? If my name is Nathan knows and I'm younger than 18 then this is going to return. True meaning. Basically the only person he was under the age 18 has to have the name Nathaniel's, and they can't drink. Now the only reason I can keep track of this very easily is first of all, I've done a lot of coronary logic in my lifetime. But I've also just written this and I had to explain it, so I had to make sure that I understood this. Otherwise, have someone just threw this at me, I would have to stop and read it very closely. Okay. If the ages over 18. Okay, this is my if statements, This is my else statement. And inside there, I also have an if else statement, which is the equivalent of saying, if some condition in here and then if some condition in here, right, you got code else other code. And in here, we've got if else, uh, if code in here and and we've got more coding here, right? This is the equivalent. Now, this might be more compact, but it's not necessarily better code. This, in my opinion, is better coat because it's easier to read. If one condition is true, check for another one. If if it's false, check for another one. You don't have to worry about struggling with all of this stuff. So that was an example, and this was not even a complicated example. This was a very basic example of when two and two not used coronary logic. So none do all this elevator music. Oh, yeah. Still find elevator music. So that's turn eri logic for you. Now. What I would like you to do is I want you to practice writing coronary logic. Great. Do something like this. Doesn't have to be overly complicated, right? Remember, always keep it simple. Keep the simpler it gets, the better it is for you and your peers and your colleagues and your co workers and instructors like me so I can read your code easier. It's just better for everybody to keep it simple. You've got your if condition. If it's true, if it's false, that is your turn area logic. Give that a shot when you're done that head on over to the next video and we'll see over there 36. Implode / Explode: all right. We've learned about a raise and associative raise and sorting arrays and multi dimensional raise and all that good stuff. There's one more thing I want to show you about. An array. Um and then I think we can move on to either switch statements or loops or something kind of cool. So what we're gonna do here is we are going to explode a sentence into an array and then we're going to implode that explain that sentence we're going to, like, glue it back together using implode. Now, if you've ever written Python or any sort of JavaScript Jackson, this is the equivalent of dot split. But in PHP, it's called No, not implode. That's the wrong one. Explode. Why, Who knows? No one really knows. Now explode has, ah couple parameters that it can take. I am not going to tell you all of them. I would like you to go over to PHP dot net and actually check out their documentation. So you have an understanding of not only how to use the docks, but that there are more parameters and I can't possibly go over every parameter for every PHP function ever. It's just it's gonna take too long and no one's gonna take the five million our course, you know, Plus, honestly, that's wasting your time because you're not going to use every single parameter all the time anyways, So let's go ahead and get started. We have a sentence. The quick brown fox jumps over the lazy dog or something like that, and we say Echo sentence. Okay, we've had a basic sentence. Now we can explode. This exploded. We want exploded on all of the spaces and we want to explode. Sentence. And that still doesn't do anything. Why? Because this function is not like sort sort will just automatically sort. But what you wanted to do. Ah, but we went explode to do is reassigned. So sentence is not Hey, spill sentence sentence is equal to explode sentence. And now we have an array. But we don't know what's in that array. So let's go ahead and we can either print are or we can use far dump sentence and check this out. So what explode did was it found every space because we told it to break on spaces. So there's one here. There's one here. There's one here. In fact, I'm just gonna do quickly. Those are all the sentences. All the spaces that explode exploded. And so what it basically did was got rid of all the spaces and said, Here's your array and you can see that the quick brown fox jumps over The lazy dog is the same as this one in here. The quick brown fox jumps over the lazy dog. Cool beans. So why would you ever use us? Well, sometimes you need to break a sentence apart, loop through and look for something in particular. Now, we don't know about loops yet. I'm gonna keep ah, that away from you just for a little bit because that kind of logic can sort of mess up your ability to learn something like this right away. But I promise you loops air coming and went to get him. They're fun. They're fun things to work with. So now we have an array. We have turned our sentence into an array. We also know that we can typecast. This sentence is equal to array sentence, but it's not going to work the same way. All it did was say your first and only parameter inside of this array is the whole sentence . So it's not the same thing. All it did was turn it into an array. So it's uncommon that let's go back here. We have our working array. Okay, Cool. So now you have an array and you want to merge them all together. Now, this is actually bad example. So let's break this off with a horizontal rule and let's create an array of names. We've done this before. We've got named Caleb. Ah, Nathan. And we have got what superhero do we want to use this time And man. Okay, cool. So we've got names in here, and if we did var dump names, don't forget chemical ends and refresh Caleb, Nathan and ant man. There we are. OK, but what if we want this all in a sentence so we could say something along the lines of, uh, your names are names, and we'll make sure we echo this Well, just as an array but weekend actually glue these together with a function called implode. So we say names is equal to implode and we want to implode. What now? Wow, Let's implode them with a comma and a space and let's implode names. And so what this is saying is for every item in the array, we're going to glue it together, and we're going to glue it together. We're going to contaminate it or can remember concatenation. We're going to can cat meat that with Akama and a space and so hit, save and refresh. And what Look at that. Your names are Caleb Nathan at man. And so now all of a sudden a raise are becoming a little bit more useful. We can start bringing them together without actually having to loop through it or do any sort of crazy programming logic in order to pull those names out. We don't have to do any debugging. We don't even have to look at Var dump anymore. We just know that names are Caleb, Nathan and ant man. And if we want to say your names, are all of them separated by a comma? We could do that when we use implode for that Now, what if we did something completely different and by completely different? I mean, actually, not that different, but we want to separate them with a pipe instead of Kama. There we go. We've got a pipe. And you know, if we want to decorate this a little bit, we could do pipe there and a pipe there. Now we've got pipes all around. So pipe Kayla Pipe Nathan Pipe ant man pipe. And if you want to do something little bit funner, I guess, Ah, we can change these all to upper case by going string to upper names and they're really all uppercase. So that is all there is to explode and implode. So why am I telling you this? I'm telling you this because eventually you're going to have an array or you're going to want to be able to put things into an array and then glue them together. This is a very common concept in programming, especially Web programming, where you're going through a list of things, you're looping through it and you want to create a brand new list. So what you're doing is you'll create an empty array, something along these lines. I'll make some space for us to breathe, and so you would have an array just empty like this, and you would have basically this four condition. So for actually, we're not gonna get into loops just yet because I've got a plan for that. So we're gonna loop one intense or what this is going to do is it's going to do 12345 all the way to 10. And we could say array. The integer of the number that's in there is equal to something, and essentially, what this is going to do is build a disarray. So this array could have 10 names in there now, with just three bits of code, three lines of code. Very, very easy. But then what if we wanted to echo all them out into a list? Well, that's when we would implode all of these together, using probably a comma in a space, because that's usually the most the most readable. And all of a sudden we have a list of people. We've got 10 people. This is funny to explain. So we have 10 names in an array that we have made into a string, and we have put into a sentence, and we did almost no work for it. And so that's why learning a raise is really, really important. Now. You don't have any homework. There's no task for this one. I just wanted to show you that there is a way to implode and explode. Um, a raise in PHP. And I think in the next lesson, we should sort of hot back to if else statements. Just one more. This one is called a switch statement. And this one's actually pretty cool, too. But the sin taxes a little bit odd. All right, so when you are done digesting all of this comes in, cleans up real quick. When you're done digesting this, I'll see you in the switch video. 37. Switch Statements: Okay. Hello. The last thing we need to know about if else if else statements in PHP is that there is technically a faster way and they're called switch statements and a switch statement, very simply put, is a faster way to write and if else, if else statement. But this syntax, the way it looks, is very different. It's not just if, ah, can I auto feel this if bam condition otherwise And it didn't, uh, else else, if otherwise else. It's not quite like that. Very similar. I'm gonna comment this out so we can see the difference in just a little bit and said, What we want here is color is equal to Brown. Let's write a switch statement. So what we're doing here is we're switching the color statement. All we're saying is, whenever this switches Chuck So we say if the case is brown and these air fairly exact you , so these don't get too complicated. Nor should they. These air just very quick ways of writing. If else if else statements, you could say echo color is brown. Um, break default Eco. No color is presented or supported, I guess would be a better word supported Break bam! Just like that. So we've got a switch statement? No, for this one, it's odd. Um, I'll give you that. So this one says, basically, the if else statement is based purely on one variable and that one is the color Now, If that color is brown, well, say that the color is brown and end your statement. Otherwise, if you don't add that break in there, watch this. It says both of them. Color is brown, and color is, uh, due to do not supported typo in their type over lack of typo. Anyway, now you can also do multiple cases if you wanted to. So let's just put that break in there so that it only ever supports Brown. But let's say we wanted to support Red Case Blue and case yellow echo cool colors. Bra color is brown. We know that already, But what if we change it to read cool colors bra? Because it is executing color red? What about blue? It's gonna do the same thing. Cool colors, breath because it's blue and if we said yellow when it's going to the same thing. But let's say yellow had a typo There's two W's in there, says Color is not supported. So it didn't match this because there was a typo. It did not match brown, and it fell back as the Elsa statement. It fell back to. No color is not supported. This color is not supported for a double typo and a double loss on that one. Now that is literally all there is to it now. This is the exact same as writing, and I'll write it down here, Middle commented out when I'm done, and I'll keep that in the code so you guys can reference it later if your color is equal to read else. If your color is equal to blue else if your color is equal to yellow else. If your color is equal to brown, you see how how this is taking me a while to write else. Eco. No color. Now I can go and copy these in here and Bam, bam, bam! And invent all of these that are out. Dende all of these at same time and copy the Brown went in here and that was a lot of work for very little output. And now when we change the color. It's always going to be the exact same two sentences over here. Now, if we look at this and feel free to add some extra space in here, which one looks cleaner? Does this one look cleaner or does this one look cleaner? I mean, if you've got a simple if else statement where you're just checking the colors or if you're just checking Ah, Boolean while billions probably a switch statement is overkill for a Boolean, or if you're checking something that could have multiple, um, if else statements a switch statement might be for you. Now there's one other thing that we didn't talk about that we've sort of brought up in. This one is multiple cases, so this one supports red, blue and yellow. Where is down here? This one supports red or blue or yellow or brown. We can actually also do the or statements and or comparison using to pipe signs. So these are not the letter l not l. It's not l. It's not I. It's not capital I. Those air pipes usually found above your return key above your n tricky, and this means, or you can also write, or depending if you have deciding enabled in your PHP. Um, but generally you're going to see the two pipes as the or so if the color is red or color is equal to blue or new or color is equal to yellow. And now here it of blue and yellow. And this looks better. But now I've got this really long if statement in here. So let's go and sort these out of it. Something like that. But I mean, that still looks a lot harder to read than this one. This one is literally You can read it. Switch the color out if the color is red, blue or yellow echo cool colors brought in here it's it's the same thing. It just looks messier, that's all. So that's a switch statement. Now I'm gonna show you one more cool example of where you can actually use a switch statement and let's do this Color is equal to we're going to use a super global variable called Color. We want to support only a few colors in this example. Okay, so if the color is equal to read, um, cool, we don't have to do anything. All we're gonna say is it could be red, blue or yellow. If it's brown, you know what actually changed that color? So that is not brown. We don't want Brown. Let's say we just want to support black and echo. The default color would be in here, and that default color could be Let's go with green. So the reason I left this blanking here is because color is already set to something that we like. We know that the color is is either set to red, blue or yellow, which is the equivalent of saying color is equal to get color, which is up here. We're just leaving. That commented out for now. Okay, clean that up and let's add something to our You are all in here. So we go. Color is equal to blue. Nothing's gonna happen because I broke something somewhere right there. Okay, so nothing happens because guess what? We haven't done anything. Echo color is the color. Blue is the color right now. If we said, uh, brown right up here, it says brown. But in here says black. And that's because this was the equivalent of saying Brown. And it checked for Brown. It matched and said actually know what override that color with black. That's all I did. So no, let's take a look at how this can actually affect our page. Let's create some HTML and inject our new PHP inside of it. So we've got a logic up here and down here. We've got more code, and this one is just basic HTML and stuff. So do Div. Style is equal to background color, whatever that color is. PHP echo color three. Black broom brown actually can't be brown, black, yellow, blue read or the default would be green. Color is white, so the text color is white. Height is equal to 300 pixels with is 100% and padding is equal 200 pixels. So this is gonna look pretty gross. But here's a good example, and the color is actually the background color is. And so now we're actually mixing or h email and our PHP together. And this one says the background color is black. What about blue? What about red? What about Ah and unsupported color was put in pink and a defaults degree, And so now we have our page actually being fully dynamic based on a switch statement based on something in the U. S. Also, now where a page is fully dynamic Now, this is not actually super useful example or an experiment, because generally you're not going to do little things like this. Instead, what you're going to do is you're going to say, if the page is the home page, include another file, and it will change everything on your page. It will change your dashboard, change your layout to change your header in your foot, or it'll do a bunch of things. Or if the pages, um let's say the pages a blood post and you just want to see that one block post it can seo that block post I d. I get it. I got it from yet searched the database for that, bring it back and put it all in. Here were this green boxes, and that is exactly how blog's work. So without actually using a database, you essentially know how a blawg now operates. And guess what. If the block post isn't found instead of color green, it'll say 404 page not found or go to the search page. Or maybe add some related articles or something like that. So there you go. That is the power behind switch. Ah, we used it in a cool little instance where you can change the color. I'm not gonna have this Lincoln here. I want you to actually read this again. Don't worry too much about what get is we're gonna talk about those later. Although I have a feeling that by now you have a pretty good idea of what get actually does . And what I would like you to do for your task is I would like you to create a switch statement. You do not have to use the get super global variable. You can use age. You could use a name so you could switch out people's names and give them different greetings based on who they are. You could give it a sport. So if sport is hockey, that could be your favorite sport. You could say hello. Hello, world. My favorite sport is hockey or basketball or different balls. You could say if the sport is, uh if the sport is something like hockey and don't ever forget that break statement. The break statement is very, very important. If the sport is hockey you could say Ball is equal to It's actually a puck. It's not a baseball or soccer ball or anything. And in here you could say Echo ball. And essentially, this is your first form of server side validation. What you're saying is it always has to be hockey blue, yellow or brown, or it has to be whatever default you have said it to. Now it can't be anything else. And this is technically your first lesson on security as well. So we're learning a lot in this lesson. We've learned switch statements are faster for basic, if else statements we have learned how to integrate it into a page. We have learned that Ah blawg Post essentially work off of a switch statement at centrally . I mean, the code is sometimes a little bit different, but the concept is the exact same, and you have learned that you can also write a bunch of code in here, close your PHP syntax and have it affect your page. So there you have it. Those air switch statements you are probably a pro at if else else if and switch statements by now, and at this point I would highly suggest. Ah, just building something small, Just a little dynamic page. So when someone enters their name in the URL, um, where it says color is equal to pink. You could be name is equal to, um, Jonathan And say, if your name is Jonathan, greet them with a big smile. Or you could say, if the name is Jonathan in in here, you could echo big image or like actually an image tag. If you wanted to, you could put a huge image in there something like that. So there you go. Have fun. And, ah, when you're all done that I don't know if the next video if you get stuck here because this was a surprisingly big video, I didn't plan it to be this big, to be honest, But if you get stuck here or if you have questions or you need some clarification, head on over to the learning to code Facebook group were there to help. All right, See the next lesson 38. While Loops: Hello, Ola. How are you doing? I hope you're doing well so far. Ah, there have been 30 some lessons. Probably more. Uh and ah, if you've made it this far, you've actually made it to another major fundamental in computer programming. And these air called loops and sew. Your first loop is a wild loop, and it's going to use several pieces that we've already learned about. It's going to use either decker mentor or an incremental is going to use, basically an if statement. So while a condition is true is going to keep repeating itself and we're going to echo and possibly can cat need some stuff to the screen? So let's go ahead and take a look at our first while loop. I mean, it's a little bit bigger for you. And let's look at the I guess, the syntax, the logic, the structure of it. So we say while something is less than 10 is currently the logic. But while something is true, do some code. I mean, that's really all there is to it. There's nothing more. It's just one thing you have to keep a note about is this. May run on for ever and ever and ever a can, depending on your computer, possibly crash, your computers will be careful with us. But chances are PHP will just time out. Eventually, it will say I'm using too much memory and I'm gonna stop running the script. That memory limit is somewhere around 64 megabytes. Um and that that could be a long time. Uh, for a website to echo one sentence so many times it takes up 64 megabytes of RAM is ah, lot like a lot a lot. So I'm gonna show you how to prevent that. And I'm gonna show you how to write a while loop. So let's say variable X is equal to one. And in here in the while loop were going to say, while X is less than or equal to 10 Echo X is the number. Um, and let's echo line break in there, make that one line. And now, if we run, this X is always less than 10 and excess never going to be greater than 10. So this will run on forever. So I'm not going to run the script now. The way to prevent that is actually quite simple. we use an incremental so X plus plus, that's it at the very end of our loop inside of our brackets. Here we write X plus. Plus, what this does is it will turn X into two and then three and then four, then five. And eventually it will get to 10 and 11 and it will stop. So that's all there is to it. And if I save and refresh my page here it is. So while it looks like I've actually written 10 lines of code in all honesty, I have written 12345 lines of code and we can we can multiply that we can say 100. So while X is less than 100 or eat less than or equal to 100 it's going to create 100 lines of code just like this. Now, where on earth would you ever possibly use a loop like this? Well, if you are more of a front end developer and you're creating one kind of style like a card or some sort of template component or a partial, and you need it to show up more than once Ah, you could make a loop so that you can see how they act side by side. If you were dealing with columns in bootstrap and you need to see you know what five columns looks like it, and you only have enough data for two. You can loop through those, and you can show five or 10 or 20 if you wanted to, and you can see what it looks like when there are far too many. The components are far too much data or the opposite. You can remove the loop and you can say, Oh, this is what it looks like when there's only one. Now you can do this Ah, little bit differently as well You can do if it's less than 100. So what less than are equal to is going to Dio is this loop is going to run until this number is 100 and if we come down here, we'll see that it runs until it's 100. But if we said X has to be less than 100 what we're saying is 99 or lower. So we refresh page, go to the bottom, and here it is. 99 is the number we can also do the opposite. We can say while X is greater than and let's give it a negative number while X is greater than minus 10. Keep running. Now this is the opposite. So this is going to run on forever. And what we need to do is we need to actually invert this. So X is going to start at one. And while it is still larger than the number negative 10 is going to keep executing. And so, every time this loop is finished, we need this to say, Oh, OK, you're done. You're done. This one cycle has what a loop is like. One full loop is called is called the cycle Eso we would say, OK, this the cycle is done, Decker meant by one so that this does not run forever. I'm gonna save. I'm gonna refresh. And there we go one all the way down to negative 10. Or if we wanted to do actually negative because it was negative night before. Now it's negative. 10. So the next thing you need to know is that you can break out of the loop at any point in time. You just need to add a little bit of logic. So if we wanted to say, you know what? I don't like using the night negative numbers. I don't really use them that often. Um, let's do this. X is less than or equal to 17. And we want this to increment all the time. And after it increments, let's say we want us to Onley ever actually go up to I don't know. Seven. Okay, we could say if X is equal to seven, we know it's going to be seven. We can break. And what this will do is this will go. 1234567 And then it will stop. Actually a lot. It'll go. 123456 And if we move this down where technically should be now it's seven now we could actually make us more efficient. We could use the strict operator because this is an integer. This is an integer and this is incremental, an integer So all the data types are the same. We can use a strict operator and it will give us the same result. All right, now, if we wanted to, we could also say if x is equal to five. Continue. Just skip it completely. But because they're going to continue its not going to execute any of this code. So this number is never actually going to incremental. So we also need to add one of these in here. So actually going to be five increment the number but continue. Don't Don't check for anything else. Ah, and in fact, we could even do this, move that down so that it doesn't say the number five. So when we refresh, we've got 1 to 3. The number five is missing in here right in there is then that should have been the number five. But we said, Oh, the numbers five. Skip it. Don't do anything. Just skip it. In fact, let's let's make it look like it was skipped. Echo. Just do blank lines and a line break. There we go. 1234 blank. Six goes up to 15 maximum of 17. But it said OK, the current iteration, the cycle is number 15 right now, so let's break out of it. All right, So that is your basic while loop you now know about break You now know about continue and What I would like you to do is create a wild loop. Don't forget, you need to be implementing at all times. Maybe just start with a very, very basic one. It's okay to start with basic ones like this and just echo the number back to the page. Don't forget to increment. Feel free to changes number as much as you like. If you really wanted to. Like, actually this number was very high. So I'll go upto ah 1000. But it's not gonna get 2000 because I've got the break statement on here. So if I comment that out, it's going to go. That s scrolling, scrolling, scrolling, scrolling, scrolling, scrolling. Hello, 1000. And if we view the page source Hello? Well, look, that's there is a lot in there, so that's a loop. And essentially all it does is loop until that condition is no longer true. This condition in here and then once I was no longer true. It will stop doing whatever it's supposed to be doing and it will move on to the code in here. So echo stopper and no, this. So the Rio 1 to 15 plus your stopper. So your task. Create a basic wild loop. Don't get too fancy with it. It's OK, honestly. In PHP, you don't use wild loops that often we use a different kind of loop called for each, Which is how we looped through database results, is how we loop through a raise and things like that. We're gonna learn about that one pretty soon. But the while loop is still very, very important. It's good to know how to loop through these things as well and is a fundamental concept off all programming languages. The idea is that if you can loop through one thing, you can loop through basically anything. And instead of writing 1000 lines of code to check for 1000 different conditions, you could write a loop that will check for one condition 1000 times, so it's a lot more efficient that way. There you go. Once you're done creating that wild loop, let's go learn about another type of loop. A better loop 39. For Loops: Hello. Welcome back in this US. And we're going to be talking about four loops now. Ah, four loop in Its most basic understanding is very similar to a while. Loop. However it does, some of the work for you are rather it. It presents itself like it doesn't work for you. So just as a recap, a wild loop looks a lot like this. So you've got acts is equal to one, while X is less than or equal to or equal to Caleb. 10. Do something in here. So you've got code here and then X plus. Plus, there you go. That's a while. Loop. Now, a four loop essentially does the same thing. So you've got four x is equal to that's a one. Ah, while X is equal to less than or equal to 10. And after each iteration X plus plus, Echo X is the number number, and we're also going to do the same thing in here and go h R echo while loop the are. And here we're gonna have a for loop. It s I'm just writing some HTML is that you can see and here we go. We have a wire loop. It goes from 1 to 10. We have a four loop that also goes from 1 to 10. And so the concepts of the loops are very, very similar. You start with a number, you keep Iterating over and over and over again until that number is satisfied. Until basically this condition, which is the exact same, is this condition is no longer true. And then after each generation, you just increment by one. So that's all it is. So these loops are very, very, very similar. But instead of having to write your own variable appear and having to manage it down here, this will manage it for you. And this will say after every iteration it will increment by one. So what happens if we said if X is equal to five? Continue and ah, what super duper? I thought I was gonna work, but I had a problem in my own personal logic. There we go. 12346789 10. So it doesn't matter what happens here. This is one of the differences, by the way, is if we continue in this four loop, it will automatically increment by one. Doesn't matter what you do. Whereas if you continue in here without implementing manually, guess what that Luke could run on forever and ever and ever. So there is a benefit to using and learning the four loop instead of using the Wilder. But there's a place in time for both of them. Sometimes you don't necessarily know what that end condition is going to be. Um, so maybe maybe you just use a while loop. Maybe you don't actually know what you're going to be implementing by or that increment is going to change. If, for example, in here, if X is equal to five, maybe you want to actually say X whips. What am I doing here? X is plus equal to 10 rates. This will automatically break from the loop because this is now. If this is five plus 10 that's 15. That's higher than this. 10. Guess what that loop is done. Or maybe you want to skip the next three and go 5678 plus nine. And now you got the last cycle coming in. So that is the difference. It's really how much control you want versus how much you want to automate Sometimes the automation is nice. It's a layer of protection at sometimes you need that extra control. Sometimes you just need to loop through things, and you need to be able to control that increments. So that is the primary difference between a wild loop and a four loop. Now, as with the while loop, which we learned to the last lesson you can use continue. But you can also use break. So you can say if X is equal to where we want a break. If we want to break this at eight, break out of it. And what break does is it says Quit looping through this. Quit your iterations. Quit doing whatever this loop is doing and move on with your life, and that's what I'm doing. So this is saying if X is equal to eight, which it currently is, right? 1234 skips 567 and it is on the eighth cycle. It will break. So there you have it. That is a for loop. Nice and easy. Once you understand loops like like a wild Lou before love is very, very simple to understand. The next one, we're going to learn is the for each loop, which is probably the most popular loop in PHP. And actually, javascript recently got it for all those people, Uh, who like their JavaScript. There's also a for each kind of loop in JavaScript. Um, that was finally implemented as well. And so you can loop through, um, items in your it's calling it terrible eso you're a raise or your objects or whatever your iterating through and PHP has had this for well, forever. So welcome, Javascript. And, ah, for your task. You don't actually have asked for this one. I mean, if you want to, uh, definitely check this out. But this one is very, very similar to the wild loop. Um, if you have the time, do it. But by no means you actually have to do this one. You'll run into this in in the code in the wild while you're looking through, like, WordPress code or something like that, or layer of all code, you're going to see four loops just like this, and all you have to do is be able to read it and understand what it actually does. So there you go. Once you are done digesting all this, let's learn about for each loops, which is by far the most popular type of loop in PHP. 40. Foreach Loops: Hello. Welcome back in this lesson. We're going to be learning about the most popular and probably the most useful loop in PHP . And this one is called before each loop. Now, why this one is useful is because it will automatically generate or loop through each of your items in an array in some sort of object in some sort of terrible fashion. And the best example is just a simple array. So let's do names again. We're pretty familiar with these. So we've got names. This is an array close that with my semi colon. And in here I'm gonna have the name Caleb. And in here I'm gonna have the name Nathan. And in here I will have Zephyr my cat. And, um, do we want a superhero for this one? Maybe. Let's go, Spider Man. Mr Spiderman. Okay, so that's far. Dump this far Dump names. You should already be familiar with this stuff. This looks pretty straightforward. Okay. Now, to loop through each of these e type for each and what it is is ah, your array as value and then you can use value, which would be each one of these. So each one of these will become that value variable. Now, we're not going to loop through array because that variable does not exist. We have it as names and we don't have to use the variable called value. We could just as easily use the variable called name. So for each name as in it or each of the names as a name, we can say echo name and be our and comment that dump out and refresh the page. And there we have name is Caleb, Nathan Zephyr and Spiderman. And we could also if we wanted to have like, Ah, I need to know about bullet in here so it looks like a list. Or we could actually put riel html in there and put like, Ah, a list item, something like that if we wanted to. And now we can actually manipulate this list. And this is where a raise actually really come in handy. And so we've learned all about a raise up until this point. But we don't really, Or I guess we didn't fully understand how to use them. We understood that we could write them. They're good way to organize data, but we don't fully understand how these air supposed to help us. So when you pair an array with the four each loop ah, your life becomes significantly better. You're able to loop through each array and get certain values. Now, there's another way to do this. So what I'm gonna do is undo this and we're gonna keep that there echo, which are refresh. We've got a little line in their cool cool. So now let's look through these again for itch names as key Fat arrow value echo. Let's do it this way. Let's go Key value we are now I save and I've got remember these indices, and this is going to look a lot like this. So I'm just gonna do a quick little far dumping here Names. Look at that. Zero is Caleb. One is Nathan to his effort. Three a Spiderman zeros. Caleb. One is Nathan to his effort. Three a Spiderman, huh? What could it possibly be printing? So this key is your index? That's this number in here. Now, if we have a multi Ah, not a multi dimensional ray, but associative array, where instead of instead of just having a value in here, we also have these fat arrows. Remember how we did this before? Where we've got ages and let's do this. 26 was Effort is to and Spiderman is Brad of 17 ish. Ah, and then what this is saying is the key is now this column and let's line us up. And the value is the age. So what this is going to say is Caleb 0.28 Nathan 0.26. And here we have Caleb 28 Nathan 280.26 zephyr dot to. And so it's exactly what we thought, but it actually get significantly better. So let's create another horizontal rule. I'm going to make a bunch of space to do. Here we go, and let's make an even bigger array. Um, one thing you want to be careful over, though, is what I'm doing here is copying and pasting. Just be careful, because when you copy and paste you were guaranteed to make mistakes. It will happen. It will happen probably once a week, even once you become very, very skilled, it it just happens. You copy and paste, and you don't realize that you made a mistake somewhere or you didn't change something you should have changed them. Just a heads up copy and paste can be a little bit of a butter. So now I'm going to use a multi dimensional array with an associative array. What that means is, Caleb is going to be a key, and he's also going to have some other properties. So he's gonna have an age. And that age is going to be 28. He's going to have a height, and that height is going to be one point 83 meters. Um, and in fact, let's keep that as a string. Um, and let's do another one height in feet, but we need that as a string. So height, feet and six foot. But that's not gonna work. So we need to escape that one. Ah, and, uh, I don't know. Let's do wait. Don't laugh at my weight, please. Um, about £175 so we can to do to Do you know what? I'm actually to copy all of these just cause I don't want I don't want you to have to watch me type all these out every single time. 23 for So we've got Nathan his age is 26. We have got Zephyr. His age is too. And we have got Spiderman and his age is 17. So now we have, like, this pretty big array, and I'm going to keep that height, the height and feet and the weight all the same. Don't judge my fat cat. He's not actually £175. Var dump names exit. I'll tell you what exit doesn't. Just a moment. All right, look at this. We have an array with an array inside of it and rain side of it and raise side of it and another array inside of it. And each one has a different age. Now, how do we get the age of each one? While we know from a prior lesson about a raise that we can at any point in time to do names, Caleb age and this Ah. Ah, Well, spit out the number 28 right there. Okay, so we know all about that. Um I said I was gonna tell you what that exit thing does. Exit is actually really cool. What it does is it prevents any code below it from executing, so it exits the script completely. So it will break things if you have any sort of included files which we'll get to in the future about including and requiring files. But what this will do is watch this echo Don't show up, and there's nothing here. It doesn't show up because once the code gets down to line 61 it says exit and PHP says, Oh, okay. Well, I'm done here, so I'm not gonna do anything else. I use that often for debugging stuff or just for showing things, and I don't want to necessarily show everything else underneath it. Just don't forget to remove them when you're done. All right, So let's take a look at this one. Uh, no, no, no, no, don't don't, because that makes too much of a mess. There we go. So now we're we're echoing the key, which is Spiderman's effort, Nathan and Caleb. And that's the key. We can see it there. And the value isn't right. Just like tryingto echoing array like we've done a dozen times already. It's not going to show anything, but what we can do because we know the structure of how this array is set up, we can say echo uhm ki being the name So in fact, we can change that name. Echo name is Ah, and then we can put the, um, the value in here so that value is it's pointing to this array. It's not technically a value. So you know what? Let's change that to array, and all we're looking for is age. Go ahead, clean that shrink the text of it. So it fits on one line. Apologize again. If you can't see that very well. Um, nothing too much I can do about that at the moment. And when I refresh the page, it breaks because I don't have ah semicolon. The Rio Keller was 28. Nathan is 26 efforts to you. Spider Man is 17. Look at that. So now we have a multi dimensional associative array with information that we can access and in just three lines of code were able to not only print out the name but get the ages of them as well. So now where data is nicely organized and at any point time we can access any of these and we can loop through this. We could even say in this loop because continue and break Also work, we could say If name is not Caleb, continue and we'll do that primarily our first rather. So that's nothing else is executed and voila! It only shows me. Or if I wanted to only show Mr Spiderman Mr Peter Parker, it is Spider Man of 17. Or if I only wanted to show people whose age is over a certain threshold. So let's say only people who can who can vote. We can say if array age is greater than or equal to 18 continue, which is actually the exact opposite of what we want, because this will target everyone who is over 18. So let's do under 18. Caleb is 28. Nathan is 26 both of these people are old enough to vote. There we go. That's a four each loop. It handles that increment for you that the wild loop and the four loop actually needs this one already knows, because this one, if we do this var dump names, I'll show you real quick. This one has a size of four, so it already has that number. It knows that it's gonna go from, uh 123 and four or in computer languages and computer indices. It 0123 size of four. And it's only ever going to loop through all of this stuff. And this is why this is the most common one in PHP. So there you haven't you are now fully aware of three of the four types of loops and PHP. There's also another one called a Do Wild Loop. We're not gonna get into that one, because, honestly, it's hardly ever used. Um, in my many, many, many years of writing PHP I have only seen to come up a handful of times, usually is by very, very clever programmers. But for the most part it doesn't come up. So I don't think we really need to learn about it. But you should know about it. Um, just so you know that last one is called a do wild loop. And if you just type in to Google, do wild PHP loops, you'll find all sorts of stuff about it. Personally, I don't think it's worth learning if it does. If it does come up, simply do a little bit of Google, Um, and you'll learn it within like 10 seconds It's very, very simple. So your task for this lesson is to create a multi dimensional associative array. That's that's a mouthful. So a big array like this with a raisins Ivan array. And then I want you to loop through each one. I want you to not only print the key, so for each name as name Fat Errol Array, or how we often see it for each array as key value. I would like you to print out not only the the key, which is the name, but I also want you to print out something that's inside of that multi dimensional race. So it could be the age, the height, the weight. It could be something custom you added in there. Whatever it is, I want you to sort of create something along these lines. This is the most complicated loop that you can possibly create. Um, and this is probably the most complicated logic you're going to create for a little while as well. Not only that, but this is actually really, really good practice for when you get into ah, raise inside of a raise inside of a raise and you have to start looping through all sorts of things. Eventually, at one point in your in your development career, you're going to start looping through loops inside of a loop inside of multi dimensional raise. And it's just going to be this crazy mess inside of your head. And then one day it just fam it works. And sometimes you understand why it works, and sometimes you don't. But eventually you'll get to the point where your brain just says, You know what? I know exactly how to deal with this. I'm going to use a four h inside of a four loop tour before agents out of a four for each, instead of a four h or a while inside of a four each. Or, you know, mix and match room generally is going to be a four each inside of a for each, though, because you're looping through an array which also has an array to loop through, such as this one. Actually, in fact, I want to show you, um, so that was your task. Basically mimic what I did here, But I'm gonna make this one step harder. Not for you, for me, Um, and you don't have to do this one. So I'm gonna go in here, copy all this and what I'm going to Dio is I'm going to loop through each person and then I'm going to loop through each value in here. So we've got for you. I get that care that one up here, too, because that's gonna clutter up what this looks like on the side. And so it's gonna loop through each one and going to say echo H three name. So that's the name. And each property is also going to have you, uh, echo you. Also, you can see that I'm writing html inside of my PHP. This is not the cleanest way to do it, but it is certainly one way to do it. And then here we're going to say, for each array as key value. So what we're looping through here is this one, and we're going to say for each key, there's a value and echo that. And so we're going to say echo, Ally, we're gonna close that And in here we're gonna say echo, You know it Just because I'm running out of space that's use the regular quotations key is equal to value and that's it. Do going to go and get rid of that stuff there with me? Said, Uh, OK, so we've got Caleb Nathan Zephyr, Spiderman. We've got their ages. We've got their heights. We've got their weights. If we change anything in here like Zephyr is not actually £175. He's a big, big cat, not fat, but just large is about £13. He's definitely not six feet. That would be fantastic, but he's probably more along the lines of like, I don't know, 11 inches or something. I don't really know the height of them. Ah, but we could see heightened feet meters. This one could be that said this one, too. No, no, is also a data type, So let's check this out. There's nothing in there. No means that there is nothing. It's the same as Void it. It's the same as, um, outer space. There's nothing out there. It's just no. And so you can see that as efforts height, um, in regular height is no, there's nothing in there. And so what I've done here is I've looped through each one. I've gotten the names in here, and then for each attribute of each person or cat. In this case, I have also looked through those. So there you go. That is the for each loop. That is very, very in depth for each loop again. This is incredibly important. Definitely. Spend some time learning this one. If you get stuck, we've got a group learning to code. It's on Facebook. Just type in the search bar, learning to code. You'll find us. We're probably the first result. We've got a big banner that says, Learning to code. Ask questions in there. We're here to help. All right. Once you have ah, major for each loop and and things were working well, let's move on to the next thing. 41. Check If Variable Is Set: all right. There's gonna be a lot of times when you need to check if a variable or ah kee in an array is set. What I mean by that is does it actually exist? Does it exist or doesn't not exist? Now the reason for this is because PHP is so dynamic and people create so many variables with this is, sometimes it's hard to tell if something is actually set. So, for example, let's say I've got a much more complicated script in this, but I want to say, uh, Echo Hello. Name and I refresh my page. It just says hello. So if I don't ever want this to say just how low Hello. Uh, in fact, let's make this a lot more awkward. Hello and welcome. This just says hello and welcome. Yeah, that's actually not awkward, but, you know, let's make it more awkward. Hello, And I should say, Hello, Caleb and welcome. But it doesn't. So now this is awkward because there's obviously two commas in here in two. Common should never be side by side. It's weird sentence structure. So how do we check to see if this name exists? Well, first of all we can set. The name name is equal to Caleb. Cool. That works, But there's no names that. So what we can do is, if is set name than echo this very, very easy. Otherwise, it's not going to echo anything. And we will say else, echo. Welcome, guest. And now we have something set in here. Now we can say at any time, just by changing, changing this name, and by changing us, I mean adding this name is equal to Caleb. Hello, Caleb. And welcome. So there we go. That is how you check if something is that. But what if we wanted to check if something Mawr comprehensive was set? Let's say who we want to see if there's a whole array of information set on someone, so Ah, we've got an array. You know, Let's call this people. We've got an array, and in here we've got person one. His name is Caleb and he has an array of information is we're talking about myself in the third person, by the way, his age is 28 or so and his favorite sport is I don't know, snowboarding, snowboarding. You got smaller. And what is his favorite food, right? Food tacos. Okay, so we've got one person in here. Let's go ahead and duplicate this and make a second person and 1/3 person. This was Nathan. His favorite food is nachos with a need with Arnie, Let's do without me 26 his favorite sport. I don't know, actually, hockey. It's not hockey, but I find that kind of money. And let's say Thantos is I have no idea. We're gonna say 1000. His favorite sport is destroying worlds, and his favorite food is, um, probably as guardian people. That's totally inaccurate, But it's funny. Okay, so let's get rid of name up here. We'll get rid of name and we'll say, If is set, people people is definitely set that exists so we can say something in there. But let's say we want to see if a particular person is set. So if it's set, Caleb Okay, so now I need a name in there because without it it still has those awkward comments. So what do we do? We could put people name. There's no name in here. Ah, we could I mean easily, very, very easily. And just put a name in here. Name is equal to your name. Just something like that. People. Caleb. Name again. I'm making the smaller I apologize if this is hard to read. Caleb people, Caleb name people Caleb name. So we can, for the most part, assumed that if people Caleb is said that there is a name. But if we're not 100% certain, I mean, we could sort of look like fools. It's like whenever you get an email address and it's like, Hi, person, you know my name. Why don't you just put my name in there and it doesn't take that much work. So what we would do in this case, we would double check. We would say, if it is that person name people Caleb name, then we can say hello, people. Caleb name. And there we go. So that all works. But if we got rid of this comment this out, so it sort of pretend that it doesn't exist. People Caleb name does not exist. It's not in here anymore. You see that blue? It's the equivalent of not having it in there at all. And so it just says, Welcome, guest. Now what? You can also Dio is you can say if is not set. Remember that, not operator. This is important people, Caleb name and that looks like a mouthful. But remember, most of that is just the arraign. That's all this is. So if this is not set, we can now go ahead and set this. So we say people, Caleb name is equal to Caleb Tall, lean and bam There it is. So we checked. If it's not set, and then all of a sudden it is set, Okay, now we can use it. So that is the premise behind is set. Now, the idea is to use this on bigger projects when there's a lot more files when the stuff going on in another file that you don't know how to access yet or you don't actually know is available. And you'll see this a lot, a lot, a lot, a lot with WordPress because WordPress is a very, very sloppy content management system, in the sense that the code is just so terrible and you'll see this all the time because you don't know what set. You don't know what the scope is. You don't know how things are technically working, and so you always have to check. Is something set? Is there a certain setting set? Is something set along the lines? If not, then I can do something, and that's because you don't want to overwrite. So if one person has a plug in, um, and it's called, uh, it's called Send emails and you create a plug in called send emails. You want to make sure that they're variables are not taking place in your code or vice versa. You want to make sure that your code is not overriding their codes and so use things like it's set to double check that things aren't being over written. Now, your task for this lesson, but I would like you to do is I like you to create. You don't have to create a massive array. Just create a regular variable. Call it name. Name is equal to fan knows or something, Um, and then check to see if it exists. If it does exist, awesome. If it does not exist, I want you to make it exist, so usually if not exist if does not exist, then make it exist. And I'm purposely I'm deliberately being vague here and a little bit complicated so that you can practice learning how to do these things without full guidance. So every now and then, I'm gonna start getting a little more vague, and that's totally okay. Remember if you got questions? Facebook group learning to code were there to help. I'll add clarity and there if you need, um, otherwise have at her. 42. Is_* Functions: Hello. Welcome to another lesson of while. I guess you're learning PHP so PHP surprise. Uh, okay. So when this last, we're going to learn about a few functions called, isn't it? String is array and is numeric. There are a ton of these functions called is functions, But we're just going to tackle the 1st 4 because they are Wow, they're really popular. And you're eventually going to need them. And especially since I've taught you about data types, I would really prefer if you could use proper data types because that's going to help you out in the future. Immensely. Now your work after work with other PHP developers. Eventually someone's going to hand off some code to you. You're gonna take over a client for someone you gonna redo someone's website and you're gonna have to redo someone else's coating. And chances are they're not going to write proper code. They're not going to use the proper data types. And so it's your job to basically figure out what data types are. What? So whenever you can typecast. So whenever you see a very well that says something like age is equal to ah 12 typecast it typecast it to an integer so that you always know that it's an integer. But there are times where you don't know what this is, so let's pretend that we don't know pretend we don't know that this is a string. Okay, so now how do we check if this is a string? Or if this is an integer or if this is numeric, it's really easy. We say, If is int and we put a gin there echo, it's an it. Okay, that didn't work. So let's see what else? If else If is String Age echo, it's a string. Okay, there we go. It's a strength, so we know that one works. Let's go ahead and duplicate this, but instead of strings to is array cubes lower case echo, it's an array. Nope. Still says it's a string. OK, let's try one more or less. Try is numeric is numeric echo. It's numeric. Okay, it's numeric. So in this sense, PHP understands that not only is this a string, but it is also numeric. Did it say that it's an ent? No, because it's data type is not an integer isn't is looking for the data type of an integer, whereas is numeric is simply saying, Is this a number in any degree? Is this a number? So if we said 12.123 it's still going to say it's numeric now, does this help while we can then say in here, if is in or actually rather because if is not in and then we can typecast it age. And now let's do a vier dump of age and let's do one up here is well so we can see before and after. So we've got up here. Let me make that smaller. The wages, Ma Okay, so we've got string 12.123 and then we said, Ah, you can't be 0.123 of a year old, So type cast it to an integer and we're going to say that is 12. We could also, if we wanted to support the 120.23 casted to afloat. And now this is afloat because it's a floating decimal point and there is a string as well . Now, why would you ever need this? That's a good question. Again, you're gonna be working with other people's code and eventually people are going to get lazy, you're going to run into bad programming. It happens all the time in every programming language, some more than others. And PHP is one of those ones where they're just so many PHP developers that there are not a lot of standards that people follow and they write some pretty poor code. And so whenever you see something like this, you don't want it to be a string. An age should ever be, Ah, an end, an integer so and or afloat should never really be anything else. So now that I've type casted that and put it in here, this is a float. It still says it's numeric. So let's add one more in here. Let's a is This is float. It's afloat. Look at that. It's afloat. And to be totally honest Ah, I actually had only intended on teaching you isn't a string is array and is numeric. But you know what is float is so simple. It's the same as all these other ones. I just threw it in there and, like, boom! Just like that. Within seconds, you learned about another function just like that. Okay, so that's not necessarily what we want. If we want this 1st 1 to be triggered, we need to make sure that this is an integer. And so we're gonna typecast age to an integer, Save the page, Refresh. And now it's an int again. The reason that you're going to need to do this eventually is because you're going to be working with much stricter code. As you get more and more experience with PHP, you're going to write better and better code. And better code means you were following standards. And so the ability to typecast the ability to check if something is an integer or afloat or is numeric at the very least or is an array because you might not even know if ages in a rain. If someone miss types the variable name and they called it ages well, ages is plural, so you might think that that's an array, so you could say, Ah, if is array and then you could possibly count the length of the arraign. If there's only one in there, you could turn it into an integer. You can do all of this stuff just right out of the box with PHP. Now what I would like you to Dio for your task for this lesson is I would like you to creative variable called age. Make it a string and then I want you to check. The isn't is float is numeric is array and is string, and I want you to see which ones work. Don't put them in else. If either do this, do do as I say, not as I do kind of thing. They re Oh, so these are all on their own lines now. So isn't look, it's new, Eric. But if we also said int, this will show up with both, It's both an end and it is numeric. Or if we forced this to be an array, look at that. It's an array, but it's not numeric, because it can't be. But if we said age zero, the first index in the array, it's numeric. And don't forget we also typecast of that age. So okay, there we go. Now it's numeric and it's an array. It's now we're checking for different things, so have a little bit of fun with that. Make sure you get the feel for Ah, what an array is what America is. Float is what an integer is. If you have any questions, don't forget Facebook group learning to code. We also have Ah, lot of documentation on PHP dot net. I mean, that's available literally 24 7 If you can't get an answer from someone fast enough on our group, go straight to the docks. There's no better source than the source, All right, Once year old done that, let's head on over to the next lesson and, ah, and we'll learn something cool. 43. Checking If Variable Is Empty: okay, Pretty soon we're going to start talking about forms. Forms are how users submit information to your service so that you can manipulate it. You can manage it. You can do something so that you can provide a service. Otherwise, you just have a completely static website built on a dynamic language that can't do anything. Now before we get there, we need to check if something is empty. Is is an email address empty. So when someone signs up for your site and they need an email address if it's empty, well, they can't sign up because that email form is required that email field is required now. How do we check that? We can say E mail is equal to, and we'll just put empty string in there and we'll say, If empty email echo, please enter your email address and look at that, please enter your email address. Now if we put literally anything in your literally anything that does not show up, so that's a good thing. This is called form validation. This is the first step in form validation as well is we need to make sure that every email addresses properly validated that there actually is one, all sorts of stuff. We'll get into that eventually, but right now we're just going to talk about empty. Yes, And so the whole premise of this is the check if something is empty. So as an even better example, what we can do is get email, and we're actually going to see this in the next couple of lessons I refresh, the page says, Please enter your email address. But in my you Earl, if I type question mark, email is equal to Ah, Caleb killed dot io. That warning goes away. It's no longer there. It's no longer needed because there is an email address. And in fact, if we do an else statement ago, thank you E mail. Bam, Dario says. Thank you, Caleb Caleb dot io. Now, as a little security tidbit, whenever you have a get parameter post parameter again, we'll talk about these next few lessons. Whenever you're taking unknown information from a user, always assume that it's malicious, always assumed that their intent is to bring your website down. And so simply echoing this back to the page is not a good idea. Now the reason for that is if I was the type. Oh, chrome, you're too good. Okay. So generally, what would happen is ah, this is called. Well, if it's a database, its SQL injection in this case is called on X S s injection. And so what I'm trying to do here is I'm trying to put a little bit of javascript in the u l so that in here, it also puts a little bit of JavaScript on my page and can execute code within itself, which is a security breach. Chrome was smart enough to block that for me. So there you are. That is empty. Ah, what I would like you to do is spend about one minute create new index dot PHP file or an empty dot PHP file. Ah, and just simply check to see if the email address variable is well empty or not. And if it is empty, ask for them to put it back in. Ask for them to put something in there and then just change that end once. Once you have a variable or a value inside of your email variable, that message should go away. And this is getting pretty close to concluding the basics of PHP. And in the next few lessons, we're going to get involved with forms, get post all sorts of things, validating and making sure that people can actually submit information. All that good stuff. We're going, Teoh. We're going to learn about it. Also, don't forget semicolons. All right, See you the next lesson. 44. Starting With Web Form Data: Hello. Welcome back in this lesson. We're going to be talking about forms. So if you remember when you were learning HTML, you learned about a specific element called form and it had a method attributes, and it was either get or it was post and actually spoke those side by side. It was either get or post up until now. That has been completely useless to you. You don't know what get or Post is. We've actually done a little bit of work with Get in this in this course. But let's go ahead and actually work with the form. You're going to formally learn what this stuff actually is because up until now it's a complete mystery, and it's completely useless to you. If you don't remember what poster get is, don't worry. We're going to go over all this, so the first thing we're going to do is we're going to create a form that uses method called get, and we're not going to actually write any PHP was going to set up this form, so let's put an input and I type input tab on my plug in called Emmett E M M. E. T. Will auto feel that for me the type is text and let's go ahead, give us a name. The name is going to be, uh, no, it's OK. Let's not call it name. His name is able to name. That's confusing. I see that a lot. Let's Ah, let's put City okay. And let's, um let's throw a label on here as well. Um, going to call this city and city name. Okay, so we've got City City name and the last thing we need is a submit button. So button type is equal to submit and not style. I don't know why type that Ah ends called submit. Because this form does not need to be beautiful. This form dress needs to work. So this is the most basic form that we can possibly use. Ah, for really adding user input into our page. So what we're going to end up doing is we're going to say a city name. You type in the name of your city. So in my case, it's admin. Tonight, I'm gonna type, submit and it's going to show up on the page. But nothing happens. However, there is one thing that did happen. You notice that says question Mark City is equal to Edmonton up here now that is actually fantastic, because we know we know from previous lessons that we can echo get City and it will tell us the city name. Now, we're not going to do that in this lesson because I want that feeling of suspense. I guess, um, we're going to do this in the next couple of lessons, and we're going to learn how to not only use, get, but how to use posts and how to check if things actually exist and when to show things and all that good stuff. So let's go ahead and, ah, create this form. It's very basic. You could probably take this out in 30 seconds or less when you're done that head on over to the next video and let's go ahead and actually create something amazing 45. GET Requests: Hello. Welcome back in this lesson, we're going to be talking about get requests, not get Quest, get requests and is actually super super simple. We've actually done quite a bit of this in this course so far. In fact, we've done so much at this point, you should actually sort of have an idea of what we're going to be working on. So the last lesson we've created a form, the method was get. And when you submit it the city name, we type in Edmonton submit and we can see that in my u R L. It says question Mark City is equal to Edmonton. That's all there is to a get request. So what we can do here is we can now auto fill this form. We can now check to see if there is a city set, and we can say that Ah, you are from a certain city. Now this again is a super basic example. But it works very, very well because eventually you're going to create a lot of forms that automatically do this because when I type in, let's type in another city. Let's type in New York that goes away. But We know that it says New York in the u R L but it doesn't say anything in the city names, so let's auto fill this. So let's go in here and type. Value is equal to and blankets always going to be blank by default. And let's type some PHP in here. But what I'm going to do is, ah, I'm gonna write some PHP and then going to re factor it, so it's a lot cleaner, so we're going to say PHP t to If is set, get City Echo, get City. Otherwise do nothing and a refreshment page and it broke because I have not enough parentheses around there. There we go and how it says New York. Or if I type in Edmonton, it will say Edmonton or if I type in literally, anywhere else, it says in the URL, anywhere else. But in the form it also says anywhere else. Now, let's quickly look at re factoring that what I like to dio is if I'm not using any sort of framework or an M V C or anything, I'll put my PHP at the very top of the page, and I'll set variables so What we'll do is we'll set a very well called city name and it's empty. And then we can write our If statement, if is, is set. You do is that's the opposite is set. Get city we can type. City name is equal to get city now, Just so you know, this is technically a security breach because of someone types in some JavaScript or a specific set of characters. They can actually break this page and cause what's called on excess scripting breach. It's now what we're going to do is because we know that city name is always said, and if there is a sea name, we're just going to override it. We can just type Echo City name and this is much cleaner, much easier to reach. Let's make this a little smaller. Save, refresh and let's do test and it still works Wila. Now, if you haven't guessed it by now, this get request where it says get here matches up with this, Uh, actually, what this looks like is kind of bizarre. It's not like a normal variable, so it's a dollar sign. Underscore capital G et, and everything comes in the form of an array. So you know about a raise? Ah, you know about variable And, you know, Or I guess now you know that this is called a super global variable. So it doesn't matter what function or class you're running. And these, like that stuff comes later down the road. But you can use these literally, anywhere. It's always available to you. You don't have to worry about scope or passing things in. And if I'm confusing you right now, guess what? You also don't have to worry about that stuff just yet. One step at a time. That's all we're asking. So now what we can say is PHP Ah, it's right. Some other stuff down here to do Bear with me. I'm gonna make some space so I can move this up way too big. OK, Petri, if is not empty, and we know about this one. So if basically, if the city name is set, bite Ah, it's not empty. So basically, if it's set and anything has been typed in here and it shows up in the well, let's let's despite something. So if is not empty city name and in here we can type um echo. Hey, Caleb, you are from it will contaminate this city name. In fact, I don't really like doing it that way. It's I find it hard to read s. So let's just do this. We're not gonna can Captain eight. We're just gonna write two different echo statements. And the reason that I have this space here is because if there is no space pH people automatically, you know what? In fact, I'm not even explained. I'm gonna show you. Look, it says you were from tests or its Edmund in which is where I'm from. Says you were from Edmonton. But there's no space. So I've actually had this question quite a bit in a javascript course of mine called javascript Essentials or learn javascript on Caleb dot io. All you have to do is, um, append a pen to space in there, and it works. So there we go. We've got a simple form that submits. And if we have nothing in here, let's just go ahead and ah, it's to to do to do. Let's get rid of this stuff. Cool. So there's nothing in there. Ah, and as soon as there is a test boom It's as you were from tests, which is probably a place, but it's not where I'm from. So your task for this lesson is to create a get form, and then I want you to check if anything is said. If something is said, I want you to echo it back now you're going to have to use is set and empty. You can mix and match this any way you like. I find that this is the cleanest way. So I've got most of my PHP logic at the top, and I've also got I mean, I've got some logic at the bottom, but I don't have to worry too much about like if the city name is actually set because it's already set up here. So logic up here. Ah, your template, your display stuff is below. Go ahead, Give that a shot. Once you're done with that, we're going to go ahead and we're going to learn about post and post is a little bit different 46. POST Requests: Hello. Welcome back in that last lesson, we talked about a get request form and you can actually see that I've still got the code. In there they get is the method. There's another super global variable called Post, and this one submits data a little bit differently from your form. Now there is a reason why we use the difference between get and post get. As we learned in that last lesson, all get requests are visible in the U. L. So if you were to type in your password, guess what? I would be able to see your password in a get request. You can see everything in the URL. So if you type someone's password or a credit card, guess what? That's terrible. Because not only can Google now index that, but that is actually visible and certain information like passwords, credit card numbers. Ah, social security number, social insurance numbers. Sensitive information should never be purely visible to the eye. And it should definitely never be accessible through the earl. Never, ever should that happen. And so to get around that we use this method called post and I'm gonna change this from get to post and what this does is instead of putting all of your data in the U. R L. What it does is it grabs that data and makes it invisible, but it's still accessible. So let's go ahead and give this a shot. I'm gonna type in my city name, so I gotta refresh here, type in my city named Edmonton and hit. Submit, and there's nothing in the well, there's nothing on the page because there's no PHP logic in here. But if I try to refresh the page so I command are or just click refresh even it says the page that you're looking for. Ah, use information that you entered. So it knows that we submitted the formal ready, and returning to that page might cause any action you took to be repeated. So if you ever see this, it's basically saying, if you hit continue, you might submit twice eso whether that's paying for something like You don't want to pay for something twice, do you? So you usually had council. In this case, it's totally fine because we're not using anything, actually, not using any logic at all with PHP yet, So we hit continue and nothing seems to change. Now. I'm just gonna refresh this page by going to the CRL instead of actually hitting Refresh. I just go up here and hit, Enter, um and that just reloads my page for me. So it doesn't give you that warning anymore. Now, like in that last lesson where we check the value, we could do the same thing here, and we are actually going to do the same thing, and then we're going to re factor. So PHP if is set post And the name, uh is city. Oh, this is something that I actually forgot to cover in the last lesson echo Post City. So what we're looking at here is, in fact, that's far too messy for anyone to read. So if we have did it did it did just making them space bear with me. Um, city is equal to post city. Okay, so we know that's post method comes from the method in the post form. But where the heck did we get city from what we got City from If we look in here, we've got this name is equal to when we can change just anything we want. We changes to city name if we want to use Camel case, uh, or if we want you snake case city name or really anything we want, don't you, spaces? Because it's just a terrible practice. Ah, and things can go terribly wrong on certain versions of PHP or certain server set ups. So never use that. Never use special characters. Just stick with plain old variable rules. So you can say, in fact, let's do that snake case city name, city name. And what I'm gonna do is I'm gonna comment this out because I just want to show you what this does. So if there is an air in there, so if its set, uh, did it did it did, uh, s we did if is set Post city. Ah, that actually use a change to city name Echo Post City. That's also needs to change city name. Um, so this is actually not going to fix anything. And in fact, let's let's use this as an example. Okay, so we've got code and granted when you're using your editor is gonna look a lot cleaner because your lines are going to be a lot smaller. I've got mine zoomed in so that you can see things. Ah, little more clearly for it. In a lot of PHP, you're going to see things like this and it gets so hard to read. So what I like to do is I like I call it re factoring a lot of depth scullery factory. But essentially what you're doing is you're taking the logic out of this one attributes and you're just going to say Echo City named We did this in the last lesson as well. It's make this little nicer because we have all the free space in the world. So bam, there we go. Okay, so we've got input value type, value city. Name it. Save on this file. I'm close that other one because that was from last lesson. Refresh. Cool. But city name doesn't actually exist. And if you've got D buggers, you've got errors on this will throw you an error. Saying city aim has not been defined yet. So let's go ahead and to find that we've got City City named by default is always blank because we don't know if someone submitted the form or not. And that's the kind of logic that we're going to start employing throughout future lessons in PHP. And so now we can say, if is set post city underscore name. And remember that that city underscore name matches the name in here. We can overwrite the city named Variable with post city name save. And if I refresh, nothing's gonna happen. But if I type admittance, there we go, it stays in there. Now it's hard to tell because the page actually load so fast. You can't actually tell that anything has happened. So let's let's add some additional logic in here. Create some room for our code on we say, if is not empty city name. So it's not the default. The default is basically when you load the page, there is no city name. We know that from here, and we're going to get very PHP e with this and we're going to actually you know what? I like this on different lines, so it gives us some more somewhere reading room. Um I mean, it's a little uglier, but that's okay, s so basically, we've got some PHP logic in here. Let's put that on its own line. Let's put this on its own line. And now if there is a city name, we can put any sort of HTML in here because we've got our opening PHP logic. We've got a closing PHP logic, and now we can put in some HTML. So let's go, Div style background color. It would help if I could type background color, red color white. And that's, you know, let's make that font size big fun size. Let's make it like 45 pixels. That's pretty big, I think. And we can type echo groups City name refresh Its going to say, Oh, hey, you've already submitted this data. Do you want to do it again? In this case, Yes. Let's do it again. Oh, hello, There it is. And if we wanted to type a different city name So let's do like San Francisco or Frisco or Ah, Los Angeles or if we wanted to do really anything, it doesn't have to be a city name either. The only reason that we're using sitting name is because of label is specifying a city name , but we could put Caleb and look, this shows up for us now. So there we go when we're talking about the difference between get and post post. If you look up in the URL, it says nothing, there's nothing visible there. It is a lot more secure for using passwords, credit card numbers, all that stuff bolt. Although if you are using passwords, make sure use a proper hash. Should be one way encrypted should never be in plain text credit cards. Honestly, just never store those those air A terrible nightmare for most developers. Social insurance number Social Security number is also very sensitive. If you don't have to store it, don't store it again should never be stored in plain text. And the last thing I want to talk about here is just this method. So in the last lesson we talked about get in this last, we talked about post. So we know that when we have method is equal to yet we're post and that we can basically say that is going to be, get post or get. So we know that when the method is equal to get, we can use to get super global variable and when the method is equal to post, we can use the post super global variable. Now there's one more called request, and it will look for either get or a post. Ah, but honestly, don't use that because it's far too vague and nobody really knows if the request is get or a post. Um, and it's terrible for security. Nobody again knows if this request, Let's say password is in plain text or not. We like we don't know if this is coming in from the u L. But if we'd say Post, we know that it's not being stored in the u. R L. We can safely continue coding with the password. So there we go. We now know about get and post forms What I would like you to do. Your task for this lesson is create a post form just like what we have here. You don't have to worry about the re factoring, but I would suggest re factoring anyways just because it keeps your code a little cleaner. Ah, and it's easier to work with down the road. And then I want you to also write some PHP logic like this where you're you're not only mixing your PHP and your HTML, but you're going to open. Ah, your PHP syntax, right? Some logic and they're an if statement, you know all about those. Now, close your logic. Put some html in here. You put some more PHP in there as well on. Then you need to close it with your opening and closing PHP syntax so that this and this match as if it was a nicely flowing if statement with the brackets, cool beans. So once that's done had on overtime next lesson. 47. Required Form Fields: All right, let's talk about some required fields. So in HTML we have this little attribute called required, and we can just type required. And when we refresh the page and try to submit, our browser says, Please fill in this field. But sometimes that's not an option. Or sometimes someone goes into your page and they hack it up a little bit in their dumb, their document object model. Now we can go in here and we can remove that, and now it tries to submit for us. So it's easy to hack up the HTML, the dom, the document object model. And we can't always rely on the fact that this is required by our browser, especially since there are people out there who still have really old browsers who just don't have support for the required attributes. So the way we get past this is we basically check to see if everything is set up the way we needed to be set up. So what I'm going to do is due to do. I know that last sentence was very vague, but just bear with me just a moment. And so what I'm doing here is I'm just going to create Ah Div for both city name and your name for actually actually been city name as well. And this one's gonna be just my regular name. So you know what? Let's call it. Oops, let's call it first name first name. And when I refresh the page Oh, it's gonna ask me because it's a post page. There we go. OK, so I've got my city name and my name and in fact, let's get rid of the required Let's just assume that this does not exist because we should never rely on that. As I just said, we should never, ever rely on that. So now we also need to have a sentence down here that says, Hi your name. Welcome to and in the city. So essentially, it's going to fill in these blanks. Now what happens if someone only specifies the city name or your own name? It's one of these is empty. Then it's going to say hi, Caleb, Welcome to blank or high Blank. Welcome to your city. It's gonna look terrible. And people are gonna look at that and go, Oh, well, something's obviously missing. This is not, you know the service for me type thing. And we've got to make sure that this stuff actually always works because a lot of applications are data required or they, ah, they basically rely on data. Um, without it, like without having someone's name, you can't personalize a message you can't say, Hey, Caleb, welcome to my website if you don't know the name of that person, So let's go ahead and check this out. We type in city name Edmonton. My name is Caleb. Submit. Nothing happens. All right, So let's add some pre defined logic at the top of our page. And let's say the city name is always blank. And let's say your name. Uh, that's not Do your nameless. Your first name is also always blank, and we know that if these are blank, this should not show up. So let's look for something here. In fact, I apologize about that. Let's make some room so you can see what I'm typing. PHP if is not empty first name and is not empty city name. Sorry must make this little smaller cause I like to put it on one line. Close that if statement and then we can move this up so I don't have to take that out again . Echo High. And today, today, uh, it's put first name. Welcome to city name. And when I refresh the page, nothing happens because first name and city name are still empty. But what if I did? City named Edmonton first name Caleb. Now we have some logic problems because these aren't showing up now. Why is this not showing up? Well, it's because we're not actually using the user input yet of this point. We're just saying city name and first name is always blank. It doesn't matter what someone puts in. It's always blank. So now we need to check if they are set. If the form has some information in there and overwrite these variables so we can say if is set post, we know it's post because the four method is post city name and we can just simply override it. See you. Name is equal to post city name, and we can do the exact same thing with first name. Just be careful when you copy and paste here whips because whenever you copy and paste, you will inevitably run into errors. You will forget to paste one certain spot. In this case, this is very simple. It's always just first name, and it's like three lines of code, so it's not a big deal. But when you deal with 50 lines, code or 100 lines of code, you're gonna miss stuff. So just be careful when you copy and paste. Now, if I say this and I refresh, it's gonna say, Hey, you already submitted that stuff. Hit. Continue. Nothing is gonna happen. But if we try once more and properly, submit the form. There we go. Says Hi, Caleb. Welcome to Edmonton. We can also add the values in here Eco city name and for my name Weaken. Say pH B Echo, first name Refresh. There we go. We've got auto fill. Cool. So now what happens if someone does not put in their name? Watch this. Okay, nothing shows up. That's a required field, but the user doesn't know that yet. The user has no idea that they are missing a field now. Usually we denote this to a user by adding a little asterisk, saying, Oh, this field is absolutely mandatory save, and I was gonna refresh here and so this asterisk essentially is saying this field is required. But you know what? A lot of people actually don't pay attention to that. And even if they do pay attention, if I type in Edmonton, nothing is happening. The user does not know what's going on, so we need to give them some sort of way of saying, Oh, guess what. You need to fill out this particular form. So let's go and do this. Let's try it with our first name first. We're going to write some logic in your PHP if is not set. No, I did it wrong. If is set post first name and empty post First name Echo Missing field. Okay, I'll explain this. I did a lot of typing and not a lot of talking there. Eso What this is looking for is is is post first name set. What that means is, was this fit? Was this form filled out? Was was this field entered in some degree. Even if it was empty, it will be set. But is it also empty? Because if no one types anything in here, it's also going to be empty. So let's go ahead and submit this there ago. Says missing field. Um, but you know what? That's Ah, a little bit too ugly, in my opinion. So let's write some quick CSS. It's right. A styling here, ah dot error background color, red whips. I don't know why I got that in there. Padding 10 pixels, font size 13 pixels and color whites. What we can do in here is we can say div class read and close that div. And by a diff class read, I actually meant def class error. I got confused because it is read a big red section. So says missing field missing field. In fact, let's b'more informative if be as informative as you can. So, um, missing first name. And we can actually apply this logic into the city section as well, in case the city name is missing. So we say we just replaced both of those posts. City aim. So is the city name set. If it is, also check to see if it's empty. If if it's both set but empty, then say missing city name. Okay. And let's do this. There we go. Missing city name missing. First name. So city name again. Let's put in Edmonton because that's where I'm from. Your name. Let's put in any name. Let's put in Jacob. And there we go. So that is how you do required fields. Now, the logic behind this is actually very, very easy. The logic is you check to see if one of the fields has been submitted. We can check to see if it has been set in either the post or get super global variables. In this case, it's post, and we can also check to see if it's empty. So now what I would like you to do your to ask for this lesson is to not only replicate this to create a required field in your form, but I also want you to take this kind of code here. And I want you to re factor this. Put this into some sort of variable up in the top page top part of your page where all the logic lives, and then I want you to re factor your if statements. So basically it should say something like, um if city error and then show the error. I want you to learn how to re factor things because this is so much more readable than this . Now go ahead. Give that a shot if you get stuck. Guess what? There's a lot of support here. I'll help you out. Either. Ask a question down below. If there's a common section or hop on, learn to code on Facebook. It's Facebook Group and asked the question there. I'll be happy to help. Once you're done all that, let's head on over to the next lesson. 48. Final Project: Hey! Hello. Okay, so this is your main project now, this project don't get me wrong is not the most exciting thing in the world. But from everything you have learned in this course so far, you can write Ah, lot of really, really cool pH be super dynamic pages that your project for this course is actually super straightforward because we've learned everything that you need to use. What I would like you to do is I would like you to create a new post form. We've seen a lot of this in last few lessons. I wanted to have three input fields not to, not for just three. Make them all required fields. So not only should they have the required HTML field, not field um, the attributes, but they should actually be required. Eso if someone was to go and hack up your page and get rid of that required attributes. Guess what? It's not going to get past your PHP because you're a great developer. I also want you to write clean code, so don't write messy code. It's it's totally okay to write gross messy code while you're you're sort of in the heat of the moment you in the middle of all this. But maybe when you're done going, clean it up, re factor your code, make it nice and clean and ledge a ble. Add comments if you have to. That's totally okay. Just make sure you write clean code. One of the things that a lot of developers don't like about PHP and PHP developers is that they tend to write really messy code. A good example of that is WordPress. WordPress is terribly messy code. It is a terrible way to write PHP. And I don't want you to go down that road. I want you to be able to write and read very clean, friendly code. So other developers who will eventually be working with you will go. You know what, that guy or that girl knows how to write some good code. Then when the form is submitted, I want you to create a success message. So basically, when all the fields are submitted and they meet the requirements that you know, they are actually required, um, put a little green message on your page saying, Hey, yeah, I think you will get touch with you shortly or your form was successfully submitted. Something like that. Just so the user has some feedback. And then I want you to also create an error message at the bottom of the form. So not only should each input field have three error messages, so each input field has its own error message, I should say, but at the bottom of the form, if there are any error messages, I want you to put that at the bottom of the form above your submit button so that if someone submits the form and all three input fields are empty, it will say input Field one you're missing in Patou input field to you're messing and field number three, you're also missing that. And then at the bottom, it should say, Guess what? You were missing three fields or you're missing required fields or just something like that , so that it's really blatant and in the user's face so that they know that they've actually missed a bunch of stuff. I'm not going to give you the source code for this. This is completely up to you If you have questions. If you get stuck, feel free to ask questions like I'm here to help. This is what I do. Um, also, there are thousands of developers and the learning to code Facebook group. So if you ever get stuck, guess what you can ask people in there. I'll help you out in there as well. I'll help guide you, but I'm not going to give you any of the code for this. You got to figure this out on your own. That's part of learning that's struggled, that you're feeling that a little bit of frustration, trying to figure all of this out. That is what's important here. That's what's gonna make this a memorable experience for you. And that's how you're going to be able to reference all of this in your head without having to Google without having to come back to this course. It will make you a better developer, I promise. So go ahead, create this amazing form. Feel free to use, um, a raise. Feel free to use print are to see what's coming back, something that we didn't talk about. You could also dio echo instead of just echo post you could do to do prints are post and you could see all your post variables in there as well. You might even see some extra stuff. Experiment with it. Have some fun. Do whatever you need to do to get this done. Um, and again, I'm here to help. I look forward to seeing your finished work. If you want to share that with me, I would be happy to take a look at it. Cool. So that's your project. Go ahead. Get started on that. Um, and there should be one more video after this. Just a quick little summary of what you've learned. Um, and where to go next? 49. Course Summary: Hello. Welcome back. This is just a Sam summary of everything that we've learned so far. Maybe not everything, but ah good portion of what we learned so far. Um, and how you can apply it. So far in this course, we've actually learned a lot. So you've learned the most important parts of PHP. You know how to get around. You know how Teoh, right? Variables, You know how to write comments. You know how to do things like unset a variable. So once it's set, you can unset it if you want to. Ah, you know about var dump or, um, print our print are are var dump depending on if you have X debug installed. Ah, you know about typecasting, which is a huge thing that most PHP Debs actually don't know about. Typecasting is incredibly important. Basic arithmetic Subasic Mass. Because we're programmers were not mathematicians. But we still need to do some basic math constants which are variables that you can not change once they're set, they're set for life concatenation which is basically you write out a sentence and you add more stuff to that sentence quotes first apostrophes where quotes in here. You can have a variable, and in here you cannot have a variable. You learned how to do string. Replace replacements. You learned about a raise? Um, you've learned that not only can and Arabi just one integer, but it can also be an inter jury can have a list of floats. It can be all sorts of things. You can mix and match all of your variables and just makes a list of variables for you. And then you learned how to loop through all over those. Now you learn to vote. If statements else statements if else statements you've learned turn eri logic, which is crazy logic. So it's not just like if something is true, it's it's really what it comes down to is variable is equal to if something is to her if something is true. Uh, 10 right coronary logic. You've learned about that. You learned about implode and explode. So you basically you taken array and you imploded into one string or you take a string and you exploded into a bunch of different parts in an array again, while loops four loops for each loops. You've checked us to see if a variable is set or for variable is empty. And then you learn all about forms, which is by far the most important part of dynamic programming languages like peach. But you need to be able to accept that user input and customize their experience. Otherwise, really, you just have a static website. So you've learned all of this in what, a few hours and honestly, this is good enough to get you going on writing any sort of Petri that you need. Now, there are some other missing components such as functions, object orientated programming, name spacing, all that stuff gets quite advanced. But really, you have enough to pick up a PHP Web site and to figure out how things are working. So at this point in time, it would be safe for you to say that you are a PHP developer. I would say you are a junior level PHP developer and that you understand all this stuff now . So with that said, I just want to give you a big congrats like, hey, you got through a lot of material very, very quickly and you now know things that you didn't know before. Now where do you go from here. Well, you can keep learning more PHP or if you're kind of second tired of PHP and you want to try something else like Python, go take a python course. Because now that you know how wild statements work, you know how variables work. You know how lists or a raise work? All that stuff is transferrable. You can learn python. You can like PHP, even learn node.js or just regular JavaScript because you have all that programming fundamental inside of you. You understand it. But in my opinion, I would say, Ah, your best next step is to continue learning more PHP. You've already gotten through the hardest part, which is getting started and figuring out the fundamentals of it. After this, it's just really getting a little more complicated with things, making things easier, learning how to write code once instead of having to write it two or three or four times over and over and over again. And then it's really just bundling that code into nice little packages where basically, you can ship it and send it to someone else, and they can use your code flawlessly in their application as well. So I would suggest Keep learning PHP because you're already here. But if you wanted to, you could pick up a python. You could pick up JavaScript or node.js, um, or Ruby, Because again, you know all the programming fundamentals. So again, congrats. You got through a lot of stuff on. And I really hope to see you in one of my other courses. Possibly my JavaScript essentials course, which is a huge favorable course amongst the JavaScript developer community. But if I don't see you there, I wish you the best of luck. Um, and don't forget, you can join our Facebook learning to code group where not only do we help with just PHP, but also python and A S P and Java and C plus plus, um, android systems, IOS systems, all sorts of questions. And there are tons of javascript as well. We're happy to help. We're happy to help. We've got thousands and thousands of developers. Ah, and we can answer basically any question that you have. So again, congrats. And I look forward to seeing you either in the next module or in another course, or just in the Facebook group just kicking around