Modern PHP Development with Bootstrap, GitHub and Heroku | Trevoir Williams | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Modern PHP Development with Bootstrap, GitHub and Heroku

teacher avatar Trevoir Williams, Jamaican Software Engineer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

17 Lessons (4h 38m)
    • 1. Introduction

      5:54
    • 2. Setup a PHP Environment using XAMPP

      15:39
    • 3. Install And Configure Visual Studio Code

      11:31
    • 4. Create a GitHub Account

      13:01
    • 5. Create a Heroku Account

      8:02
    • 6. How PHP Works

      28:52
    • 7. IF...ELSE Statements

      18:55
    • 8. FOR Loops

      10:27
    • 9. WHILE AND DO...WHILE Loops

      14:20
    • 10. Arrays

      13:21
    • 11. String Manipulation Functions

      27:42
    • 12. Date and Time Manipulation Functions

      14:56
    • 13. User Defined Functions

      22:15
    • 14. PHP Include and Require

      22:08
    • 15. Website Layout - With Bootstrap 4

      22:48
    • 16. Add Project to Github

      8:24
    • 17. Publish Final Website on Heroku

      20:09
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

96

Students

--

Projects

About This Class

This course is designed to equip students with the basic knowledge beyond how PHP works with HTML and CSS. It equips students with the fundamentals of PHP programming, teaches them about the benefits of using source control and ultimately allows you to publish your finished website to the internet.

PHP was designed to make web development easier, and many beginners find it effortless to pick up and get started with. In fact, PHP code was so easy to pick up, many non-programmers end up being able to hack PHP code together without truly understanding the code.

The top 5 reasons to learn PHP are:

  1. Beginner Friendliness

  2. Designed to Scale

  3. Active Support Community

  4. Career Opportunities

  5. Future

At the end of this course, you should be able to:

  • Understand the PHP Application Flow

  • Understand how to use:

    • Variables

    • Print Statements

    • Arrays

    • Date/Time and String Manipulation

    • Functions

    • Loops

    • Decision Statements

  • Understand Bootstrap 4 CSS Framework

  • Use Visual Studio Code Efficiently

  • Deploy using Heroku Hosting

  • Manage Projects with GitHub

Meet Your Teacher

Teacher Profile Image

Trevoir Williams

Jamaican Software Engineer

Teacher

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: Hey, guys will come to this exciting new course. Applied Web development with BHP I am your instructor Trove or Williams. In this course, you will be learning the fundamentals off Web application development using HTML CSS PHP Patchy server ONDA hosting tools such as Hiroko and see Panel Off course. All of that wouldn't be complete without tying it in with a my SQL database so that we can have a fully dynamic and data driven up Web application. By the end of this course, you should be able to accomplish basic Web development with HTML and CSS, set up a zump server, understand the rule off PHP in Web applications. Build a my SQL database using PHP. My admin on all of that would help you to build a data driven and dynamic Web applications . We'll be looking at PHP PDO on hold to style or application using the most popular CSS framework. Bootstrap. Ultimately, we would want toe incorporates the use off source control through the use off, get hub on, ultimately host our Web application on Herro. Most other courses will teach you how toe understand Ph. B ho to do the basics off pH. People they don't really show you the end and development process, and that is what we hope to accomplish in this course. At the end of this course, you should be empowered and equipped with all the tools you need to build any application. That is our stuff. You. No. Before we go much further, I want us to take the next two minutes toe. Understand that the tools that will be using on how exactly they work in the whole Web development ecosystem. Let's start with PHP. PHP is an open source Web scripting language, which is used mostly for service side stuff on it, is short for hypertext pre processor or personal homepage. PH B is designed to be fully embedded in HTML and manipulate HTML as you, the developer so desires. If you have any exposure to any other programming languages such a C possible C sharp or job, then you find that it's very familiar working with BHP. If this is your first time working with any programming language than that's final because we will be starting from the ground up, the next big ticket item would be zump Server on zump is really short for well the X really means any environment. The basis off some server is really what we call the lump stuck That's ill. A MP on D l really means Lennox, the A, Apache, M, my SQL and P PHP or PERL. So zombies really just on adoption off the lump stuck onto other operating systems such as Windows and Mac OS. Since Slum, the El sends for Lennox on it is the most popular PHP development environment. It's a one stop shopping installs jump. And then you get that Apache server, which is required to Horst PH. B chord. Ah, you get my SQL, which is a database server on you. Get all the required libraries for PHP on Well, Pearl, but we'll be doing PHP. So focus on the PHP libraries on. More recently, the M also means Maria DB, which is a spinoff off the more popular my SQL database engine. Now here we take a quick look at what HTML and CSS and PHP will look like. Well, this code snippet has no CSS in its just yet. But there you see that you have some HTML, which is the black text, and then you have the PHP tugs that were previously alluded to on some cord, which would print some text inside off on a HTML pitch. Traditionally, issue more pages. Have the extension dot html or dot h t m. When we're using Ph. B, these files will have the extension dark. PHP on these PHP towns will only work in dark PHP files. But as we go along and we get into more development stuff than you, see how that works now, every step off the way we will want to track our progress on DWI will be doing this using source control on more specifically through get hub. Now get Tobar by extension. Source Control allows you to track changes to your project. Collaborate with team members if you have to work in a team setting instead of copying and pasting called fast ickiness, upload to a central please that everybody has access to all of your changes. We can also manage project documentation centrally at the end of the day. Guitar is probably the most popular and also free source control tool that is on the Internet, and it's widely accessible, widely available to everybody on. Once again, it's free of charge. The last thing I want to mention is Hiroko, which I loves us. The deploy PHP Web applications. In minutes on, we can host the Web application as well as the database all on Hiroko. We'll also be looking at using the more traditional route, which is C panel. I didn't allude to it here, but as we get into the course, we will see how valuable those tools are. Once again, we have an exciting journey ahead of us, and I hope you stick around and I hope you apply yourself at the end of this course. You should be able to take on any challenge that comes towards you in PHP. Web application developments. 2. Setup a PHP Environment using XAMPP: Hey, guys, welcome back In this video, we will look at installing the Samp Server application as mentioned before some is the most popular PHP development environment on the letters really stand for Apache, which is the Web server Maria DB or my SQL PHP and Pearl. Here I have navigated to the website and a link, while a direct link to the download Peach is included in The resource is for this video. But here it is. Apache friends dot org on From here, we can go to download and proceed to download some free off cost as it is open source and free for public use. So I just go ahead and don't know that, and we can reconvene when that process is completed. Having completed the download, we will be met with the set up on its fairly straightforward. I'll just go ahead and click next. We don't have to change anything here, as all of these are either essential or very nice tohave. As you can see, that matches by default Greedo because it makes no sense to install zump without Apache. But we can leave everything else sticked on. We can just go ahead and treat. Next, we can go ahead and perceived with that default folder. If you have another folder that you wish to use them, that's fine. But essentially, this is where all of the server Ph b. And by ask your files will be deployed toe and ultimately, where we will need to put our sites for hosting on the Web server. But we will just click next on. Go ahead on and proceed through the installation. All right, so here we see that bit. NAMI is going ahead on promoting some models. Tow us for them. We don't need those right now, but these are, like, ready made applications for us. But we don't need those right now, so we can just go ahead and click next to go ahead and install at the end of this set of process. We can just go ahead on and finish Onda. We can choose Well, our language. I'm sure they have language box. For if you're neither of English speaker or a German speaker now then of the set of their associates wanted to launch a control panel to which we said yes on from here, we can actually start our services individually. Now, as I start them, I'll give us a brief explanation as to watch each service. Those Apache is our Web service on. Essentially, this Apache service is what allows us to serve off our pH B or pearl or there are are other languages that could be hosted on Apache. But since we're doing a Ph. B classes, focus on PHP on. Without this service running or PHP code simply will not work, so we'll be running queries to the database. Using PHP will be trying to displace, earn information and run certain maybe logic and business logic using PHP. But if our Web server, which is called Apache, is not started, then all of this will be no envoy. So we want to start Apache firstly on. Do you maybe asked alot access? You can go ahead and do that. It's a local server, so there should be little to no harm. Also, we should know that Apache Server by default uses Port 80 which is the default http Port also for 43 which is the default SS supports. Those can be configured because there might be a situation. We have conflicting Web servers using port 80 and off course, once their conflicting the neither will work. So you may need to change one to facility the other. So since Apache is the only one we have that is active on this machine, Port 80 is our default port. The next service that is very essential is the my SQL service. No, my SQL is a database server. Apaches, A Web server. My school is a detail. Be server. No, my SQL needs to be enable force a facility it offline. Storage off data off line. Start off. Data means that if a user, for instance, registers for a website once they click that submit button, that data that they entered in the registration form needs to be stored somewhere on that is the purpose off my SQL in the hole Lump stuck. So my SQL needs to be started and we just go ahead and click. Start on once again, a low access on once it's in the green, you know, it has been started successfully and the default port for my SQL is 3306 Now, file Zilla is actually an FTP client which would allow us toe upload our files to some hosting agents. When we get to the point where we're actually going to upload our website, toe, see panel or any other one post, then we will definitely need to use fire zilla. But for no, we don't need to start fires. Ella on the Tomcat is also another Web server, but it is usually used for Java and other languages. In this situation, we already have Apache, so we don't need Tom Pack. No having enabled or essential services, we can verify that Apache what service is enabled by just going back to your browser? Onda looking for local host so local host is the default name for the machine you're using . If you've never done networking than then, that would be new knowledge. So any machine you're on is referred to as local host. And if your Web server is running, typing local host into your browser will roll to to the default page. That would be served up by your Apache server now in the case off zump, because based on the flavor off the patchy implementation you're using, you, me get a different default pitch in the case off some, this is that default page on. It's merely information a leak in return it and see what It's a boat, but essentially east for informational purposes on the next thing we want to verify is that or my SQL service is started properly. And to do that, we can go ahead and click on PHP. My admin. So you see, they have a bunch of links here. You can click on PHP info, adjust middle click. So open it in a new tab on we can open Ph FEMA admin. So PHP info shows you the PHP version that you're working with, which is 7.1 point 31 Andi. It gives you some other information as toe what is enable than what you me have access toe through this installation and implementation. If you scroll down, you will also see a few details on the Apache environment on one off. The very important parts would be where the folder parts are. So they show you that the document root is at sea. Some HD docks. We'll go to that in a few, but just take notes off this path. It means that any PHP application that you're about to build needs to be hosted in this path in order for a party to be able to serve it up and treat it with the regarding needs to be treated with on If you continue to scroll through, you see reference being made two different models that are enabled, some of them are important. So them you can look at a later time on, right? No, we'll just keep ahead on Look at our my SQL implementation, which is shown to us by the tool pH FEMA admit now, PHP. My admin is a tool that was given to us along with our installation. On it is a Web based my SQL administration tool my skill database administration, to So you notice that it makes her French to a server at 1 to 7.0 dot 0.1. So this I p address actually resolves two local host are the other way around. Rocca Host resolves to the i P address 1 to 7.0 dot zero dot wine. So that's some good knowledge tohave if you ever want to, bro, stow the Web server on your machine that is the local machine that you're using. Then you want to either say local host or you can directly type in the i P address 1 to $7.0.0. Not one. No. In the case off ph. Dreamer admin is actually showing us all off the databases that are currently in or my SQL installation. So that's just very fine that my SQL is running properly on if I want to create a new database or make modifications and existing one. This is where all of that magic can happen. Now point to note is that when you're using peach be madness. Sorry if you're using zump than you see reference being in tow my SQL sometimes and you see your friends being made to Mario db. What happens is that it's essentially the same service, the same protocol, but one is a spin off off the other. So my SQL was around and then Maria D. B is a spin off off my SQL based on the same technology. It may be just that differing philosophies. So you see both of them being used and told it in the Ph. B developments. Fear Web spear. But essentially the principles or me and the same, they are both very popular databases used with BHP to build dynamic Web applications. Now I'm going to do something. On day, I'm going to create my own page inside off the Apache Web server. So I'm going to navigate to the path which was see slash Zampa And there it is. On we see a number of four others, including the PHP, the Maya school and the Pee Stream admin. I would advise you not to trouble any of these unless you know exactly what you're doing. But you don't have toe move or modify anything in this folder. But we want to target HD docks because this is our folder to put in what we want. No, in our Web server, we will see that we have a page called ph b index dot PHP. Now, this principle is pretty much widespread across every most if not all, Web servers. The first page needs be called index dot Some extension. It could be index dot html in the case off Microsoft Developments Index that SPX, but in this case is index dot PHP. The factor means that if you have ah web application developing the first page that you want to be processed. He needs to be called index dot PHP on. That is why, if you go to facebook dot com, a page comes up. Even though he didn't specify, slash this speech dot PHP So that's is exactly hole Web servers work. If you want the first pitch to be rendered, it needs to be called Index that some extension and in this case, PHP. So what I'm going to do and this index dot PHP is what comes up when we navigate toe local host. Or rather, it has roading rules that navigate us to the dashboard folder on Defy Take a look inside off the dashboard folder. Then you would see that in the dashboard full that there is also an index speech on this end experience, actually an issue Mahfud. So that just drives home the fact that the page just really needs to be called index the extension. Well, we can work on that. So in this case, were either working with index dot PHP are index dot html. So, taking from that example, having dashboard, what I'm going to do is create a new folder on I'm going to call it New site and inside off new sites. I'm going to create a new file, just the text documents, and I'm going to call it index dot PHP. Now the purpose behind just creating this folder and this file is based on the principle off dashboard we saw when we navigated the local host by itself, and I'll just do it again. It would have wrote it to local host slash dashboard. That's probably because in our index dot PHP fire here, there's some logic that would rewrote it toe another path on that path. Being local forced slash dashboard means that local host represents HD docks on. Then the slash dash border presents some folder inside off HD docks. And so that's a principle that we'll use going forward any sight or application that we're going to be building inside, off or up. Actually, server, we need to put it in a folder on off course of first name. The first file in that folder must be index. So we're following that principle here where we create a new site on inside new sites. We created some fire fall index dot PHP on now. Just quickly edit this file on. Did I just say Hello world, the universally acceptable I t freeze. And so the supposition is that if I say local host slash new sites, then I should see something rendered in my prose are seeing Hello World as I just depicted in my documents. Actually, I just realized that this is the next PHP doc Txt because it's still a text documents. So I'm just going to quickly and it's the file extension. I just see a lot of you and say file name extension So it's displayed. CC's index dot PHP dot txt I don't want that Txt. I just want that PHP So I just removed that on. No, it will be a PHP file. I can ignore this warning because I know what I'm doing on DSO Windows is stunning us. It's a PHP file, so go ahead and it navigates local host slash new sites. And there we see hello world like we just typed out in our documents. So, as you can tell, I have no real tools. It it's It's very annoying here, using PHP and using note pad, and it can become quite complicated using no part but for our best purposes are at least for the purposes of this exercise we see here that we have accomplished and learn hoe to use our up actually server on DSO. In the next exercise or two, we will be installing relevant tools that help us expedite over development processes. 3. Install And Configure Visual Studio Code: Hey, guys. In this video, we will be looking at installing visual studio code, which will serve as our development environment for, or PHP Web application development. Now, visual studio code is a very open, very flexible i d E. It serves as a basic text editor that is capable off being extended to basically whatever you want. Whether you want Python you want see Sharp are in our situation. We want PHP so I can just grows to the website, which is called up visual studio common. Then you see that the download button is right there, but it is also multi platform so you can access it for Mark toys on Lenox if needs be. But I will just proceed with the Windows installation. No, you can go ahead on Accept the license agreement, and it's a pretty straightforward installation. You can just go ahead and click next. Andi you can take if you want a desktop icon on, I will just actually just take all of these options on. Go ahead and click next to make sure that it's fully integrated with our environment on. We go ahead with the installation at the end of this installation process. We can describe it and click finish while leaving the launch visual studio code option open . No, we will be exposed to Visual Studio Court as our I d. E, as you can see, is pretty basic. There's nothing flashy about it because, really, it's like a bearable and sticks editor. We can actually just open up a new file on. We just type in text. We can tap in anything on. Then, when we need to see the file, then we can determine what kind of file it is that we want to see, whether it's a text file, a c file, and again see that it has called support for quite a few files with pH. B being no exception. So what I'm going to do here is actually open our sites that we started building work, all that. We created a folder called New Site on. We had a file in the start PHP on DSO. What I'm going to do is go ahead and open its by going to file on. We can open folder and then roast the holder. I have it here in my favorites, but I'll just say the long route for your benefit. So it's this PC Windows some HD docks on. Then we find it. So when we get to the point where we have multiple applications in our HD docks than we just select the application by folder in this case new site and then we can select folder Andi, I'm not going to see if any changes made to this on titled file and there we see kind of refreshes itself. And then we get a folder structure here in the Explorer pain. So new site only has one file, and we see it gets a little Ph b elephant looking emblem. So it has contextual icons based on the file type. We give you a different icons. So if I put in on Index that issue page for human sick on, do that again, let me just do that's over. Sorry. So it creates a new file using visual studio code weekend. Just go ahead and click this icon right here that's is in file. We can create a new fuller essentially using this Explorer P, and we can manage the whole folder and file structure off any sites that we wish toe manage . Using this tools so I can just lay the increase and you file on going to call it a boat. Start PHP and you can see based on the file extension that this icon is changing. So this is the generic I quantify. C html. It changes accordingly. If I say C or H if I say CS it c sharp. So based on what file type it is, it will more according me. And so I tapped in a boat dock Ph. B on. You may see some some error messages coming off along the way, but essentially we can modify on customize visual studio code toe our development needs. And that's what we're about to do now, since it is bearable insults of the box. What we want to do is make sure that we have all of the tools we need for PHP development, so I can just go ahead and click on this icon, which says extensions. Andi already it is recommending a bunch of extensions to me because it is contextually recognizing that I might be doing THB development based on the files that I have open so I can actually go ahead and install all of these the intelligence will allow us toe are to complete our according phrases so just installed back, I'll go ahead and install Intel offense. So everything that has been recommended installed so visual studio code is actually also open source on day have a very active community where they allow you to create your own plug ins on Apollo toe on share with the rest of the world. Now, some of these in solutions might feel and complain that they can't find the PHP environment variable or whatever. So because everything was set up inside off the Zam folder, it may not have been made public to the rest off your computer. So we're just going to go ahead on go to settings so we can file and then preferences and settings. And from here we see a bunch of cool features. You have an odyssey of the Lee. We also have auto sear, so I like the art receive. So I'm just going to change it after Billy and that the video Lee is about 17 on. We can customize how we wanted to look from here, but what I want to look for is the PHP settings like this that Ph b here, Andi, it will kind of filter or all of the PHP related options. And the one that I want is the excusable pastoral. Just spend it in sitting. Is that Jason? I said no. That were in the sittings that Jason we can go ahead and type each be dot valley beat, not executed a path. And we can just finish with that Onda we would have to type in the part relative toe our installation, so recall that our Ph. B would have bean installed with some. So we went exam folder on going to peach before there. Then we need to point. So the PHP that e x e file here so we can actually just eat that path as it is written right there on. Then we go back over to our Jason on. Then we hope in quotation mark on the paste, that path. But then you just switch these slashes on. Then we say slash PHP dot exit. All right, so having done that, if you are successful, you notice that the warnings would stop coming up. I'm still getting one warning for ph PCs. And if I double click on this and go to manage the extension. Then you'd see where it's suggesting that you use in composer to install it. And they give you the composer command toe run relative to your project. I'm not quite ready to go there just yet, so I'm actually just going to go ahead and in the extensions being just disable this extension so that it will stop, you know, badgering me on. Then you would see reload required. So we can this really visual studio code on that extension would be kind of disabled on in the background. No, please know that not all the extensions are completely free. As we see here, that Intel offense is actually asking for key. So we can, you know, by the process off elimination team that won out because I don't want you to have to go and spend any money. So I'm just going to go ahead and on and start this one on reload resource to your core once again. And so we're left with two very useful and very free or at no additional cost to you extensions that can be used to help us develop Ph. B. So I'm going to go back to the Explorer pain where I have my index file where I just printed hello world simply on by a boat pH on just so that we can see hoe over Arthur. Complete works in PHP. We have a tab. Well, we have our angle brackets. Question mark of the words he used to be. And then we close that using the question mark and out of the bracket, and then I can say something like Echo on some string on the part we had to do that would have been Hello, world. All right, so this is how you would print something Impeachment. I'm not quite ready to start with beach people. I'm just showing you hold that intelli sense really works where it kind off suggests to me what I me want to type and kind of gives me an explanation as to watch. This command will do now quickly. I just remember that there is on mother environment variable that we need to sit on. That is the executed path. So if I go back to settings which you can goto file preferences and settings and I filter on PHP, then I will see that I have the validate execute herbal path and I just have the execute herbal path. So actually said validates executable part. I need to just set the executive part. So in setting, understand, to click on the edit in settings that Jason real quickly Andi, I'm just going to remove that line. So this is where we left off in the next nine. After putting a comma, I'm going to say open quotation marks and Ph. B and then you see, not executed the path on pretty much. It's the same path because it's the same PHP that we're working with. And then we can deceive that if you don't already have our deceive enabled on that should care of some things on. That is pretty much what we need to do to install over editor for our Ph. B. Where the application development. If you have any questions or suggestions, you're free to drop me a line. But that concludes this video on when we come back, we will be looking at installing or setting off ghetto on get up account and pushing this project to get up for the first time 4. Create a GitHub Account: Hey, guys, In this video, we will be looking at setting up get hub accounts and installed in the desktop Client. Now get up is one of the largest open source development platforms that you'll find. It will allow you toe remotely host your cord, meaning you can host airport on their platform on DSO. If you're seeing machine crashes with all of your source food, then you would have been checking in all of your changes on a regular basis and they would all be, you know, documented and archived on ghetto. It is based on the gets protocol or the get technology, which is a very popular source control technology being used worldwide on DSO. If you understand how to use, get through this exercise, then that will equip you to set put into any organization on understand ho to use. Source. Monjural Guiteau was recently acquired by Microsoft on its remains free free because it allows you to source their cord. Andi, once you do that on the free basis than your code is accessible, toe everybody on the Internet. They do alot it a forced it privately, but that is with some restrictions, and then you can also up for the business option, where you can pay a small fee, mostly on have your core locked away from everybody who you don't want to access it. You can get to get told by type again. Get top dot com on signing open. Creating a new account is as easy as literally 123 putting a user name and email address and a password, and then they will verify that you are you and you would be on the platform. I already have an account that I will be using so I'll just go ahead and sign in and I can use my user name, which is true for Williams and my password on. Once I have done that, I would have loved in. I can see off my repositories. I have repositories from previous expeditions you probably don't see you would have an anti pain, and you can also go ahead and follow people. You can search for people here and follow them. Follow all of their activity on the they can in turn fully you and keep track off your progress on the platform. Now they're two bits of software that you will need to install The 1st 1 is they get self tour. So I'm just going to also search for just the word gets Andi, I'm just going to don't Lord the kits. So this is a library that will allow me to run get commands on my computer. So I'm just going to go ahead on don't know this on install it on the In addition to this, we want to don't know what the gets hope for. The stops are going to say that. Stop that kids hub dot com which would lead me to this site on DSO. What you realize is that get is actually very, very common lying driven. So there are a bunch of commands that this client here, with the lows to run to interact, it's get on. Then what it has done is obstructed the need for all of those commands and giving us a desktop application. So in this video, I'll be showing you hold to manage your product using or your projects rather using the common land version on the desktop version. So, firstly, let's just walk through. Installing gets Onda. We can describe it and flick next with most off these options. We don't have to change much Onda once we get through all of that, that the installation meal different for the environment that you're installing it done. But ultimately we just want to get gets on the computer. At the end of this, I can just antic the release notes and I just finished on then to see that get is properly installed. We can go ahead and launch our command prompt window. I already have my open from when I was doing composer, like in the strike get all right, so that didn't work. So I'm just going to read open my command problem too, you know, on Let's try that again on DSO that looks more like it. So when I type the word get, then you should see something like this and that verifies that get has been installed successfully. No one you don't know. Then install. They get hope for best stop. It will just ask you to sign in or sign up if you haven't already done so. And that is a pretty much straight forward procedure is not really an installation, but it's kind of like a standalone up as again. See it is built with electron, which is a new technology for building, cross site or cross platform applications. Now they're number off ways to get your cord from your computer to get up. And in this case, our court would be these two files and or folder called new sites. So we started building aside, hypothetically speaking on, we need to have a remote copy off over work on guitar. So what we're going to do it is go on, get hope, having already signed in and then we can create a new repository on, I'm going to call it new sites. So I'm going to give it the same name as the website that I can give it the description, a sample site or PHP tutorial. All right, so that's a quick description. I can leave this public or you can choose to make it private. That's fine, but I'll just go ahead and take create repository. No. Having done so, this is basically an empty space, considering that there is nothing here. We just created it so that he was a bunch of commands that we can use to get our files from our computer into this remote holding space. They also are lost. Use our desktop. So I'm going to go with the creation off or pushing over cold from, or computer to this remote site. First on, as the course goes along, we'll see how we can use the best stop. So I'm just going to bring up my command. Prompt. And the first thing I want to do is navigating command. Prompt to the folder that my project is in so I can do C. D. C. And I know it's in some I can just for stop the auto complete HD docks on new. All right, Andi, know that I'm in the site in the in the side folder. Then I will start running these commands. So the 1st 1 I want to run is get in it. So I don't want to create a file. I really have fast. I don't need toe create this file. So understand, to go ahead and say it gets in it, which is going to initialize a local git repository. So the thing with get is that you have a repository on the machine and you also can connect it for synchronization purposes to our remote repository. So ghetto is the remote one. But we, by installing git, would have set up our own local repository, someone to say, get in it, which is goingto give us a little fire there just to say okay. Aside, git repository exists in this folder. And if we look inside that folder we owe it's a hidden file, so you wouldn't see it automatically there ago. So we see that that was created. I just went to view on view hidden items. And there we see that that finals created no. As we continue our process, we then say, get commit. So this gives command essentially allows us to add a tug or a notation toe what we're about to do. So this is our first time pushing something to the repositories so we can just say, like, first commit our initial commits. That's usually what you see. But then let's see, we have to change the menu. Are we changed the button? Then you would want to be very explicit in this commit message, so that if somebody else if you're working in a team and somebody else comes along, they can surmise what changes is the there are in this comet toe the remote repository. So this is especially useful for when you are looking back at the changes you made versus when somebody else has to look at all the changes you need and make sense of it. So you want to be old enough, descriptive enough with these comic messages so that it works well for other people. So I'm here saying gets committed. But what I first need to do, is it odd? Doesn't need to add all of 1000 depositor in the folder. Sorry. Someone to say, get add a full stop. Which means all So I'm adding all of these files to the register, so to speak. So once I do that, then I can see get commit once again. And there you see that I'm getting a different message because, no, they're added to the register and they're saying Okay, No, I know about a boat and I know about infects, All right. And know that I have committed what I need to do is push. But then in orderto push, I need what you call our remote. So if you look at this line here, it is basically giving you like a path toward the call are remote, Andi. Then you just break it down. So I get is the command remote is the sub command and then we're seeing We're adding a new remote on. We're calling it origin on. This is the path to this remote, which is really just a pass to this repository here on get up. All right, so I'm adding our remote or I'm creating a new variable or are key word, so to speak. Called Origin on this origin represents the path toe the remote repository on guitar. And then, after I had this new keyword, then I will need to push to the key word on what we call the master branch. Right? So I'm just one step in those two commands quickly, it's remote. God, origen. And then I'm just in the type of that Or I can just copy in pieces. I can just eat these hockey here on then I can just here will to edit and peace dissidents off the type of that long path and risk media mystique does. That can be a point of frustration. And then when I pressed enter, you see, we didn't get an error message or something happened on. So I'm just going to copy this command, know that we realize we can just copy in peace. And I'm just window piece. It's here and pressed. Enter on, then. What it will do is connect to this repository here and get a job on. Then Sen defies over. But then it's asking it a log in. So I'm going to have to log in. All right. So I'm sure you're seeing that this looks like a lot off work. I can assure you that this is a one time set up when you just set up your positive and you want to meet that first permission. This is a one time thing on then. Further to that, that is why I get top created their remote, their their desktop applications. So even though I know it's his love on field, some which have to try that again So user name on the password. Andi, we go. So it was successful. And so once that is done, if I refresh on gets up dot com this repository, then I will see my two files on my commit messages. So, once again, if I make a change toe any of thes files on my local computer than I will need toe push those changes here so that somebody, if they land on the spirit, they can see all he made this chance of this fire at that point. And that is essentially what ghetto B is used for as we go along in a project to see it in a more practical form. But this is really just to get you started and have an appreciation off why we need get up . 5. Create a Heroku Account: Hey guys. In this tutorial, we will be looking at setting up a hero who account heroic, who is a very popular platform as a service or pas for short on. Essentially, they allow you to upload your code and host the website with very minimal efforts. They support automatically scaling your sites based on the website lowered Andi. Essentially, they take away a lot of the infrastructural requirements and considerations that you would probably meet when hosting a website's up until this point would have set up ZUMP with Apache server on our local machines and that would allow us to bro store sites when we're on our machine or probably over a network share. But then, when we wanted to be published on the Internet, we probably don't want the hassle of setting up Zampa on an Apache server and configuring it for Web access and a lot of fire wall rules. So what a pas or in this case, Hiroko allows you to do is abstract all of those configurations and set ups and considerations and just put your coat there and they will take care of all of that infrastructure and set up and hardware consideration for you. Herro Coat of the box supports number off languages, including JavaScript, ruby on rails, python. But for all purposes, PHP on day also support hosted database services like Clear DB Server, which would be used for over my SQL Server hosting. It's where the to know that Hiroko is also free on you can start paying for certain Adan's and certain customization is what out of the box, they are free. And so today, what we're going to do is just go ahead and set up or a cone. So you see the button here. That's a sign up for free. We can go ahead and treat that on signing up. It's pretty straightforward. They just wants your name, your email address. The company name is optional role that you be playing the country on. If you're a robot, are not. After you've completed this form, you can go ahead and sign in. I already have an accounts are just go ahead and log in. After logging in you. Bill, let your administrative dashboard where you can manage any up that you may have. Since this would probably be your first time here, then you would have no absolutely can go ahead and create a new one. If you wish on, you can walk through that so I can see a test. Ph b. Okay, so what happens is that out of the box it is going to give you sub d amine. So whatever your app name is, you get that as a sub demean off the herro who site. So you want to make sure that your app name is very unique. As you see, it was validating that and he can choose a region. So I'm closer to the United States regions. I leave that there and then I think, create up on what it does is give me the ability to deploy anything that I want to this space. So it kind of creates this container similar to hole. We would have set up a folder in our Apache server and then filled it with any resource is needed for our site on hero who they created this container and then they give us tips. Us the whole We can deploy anything that we are working on to this container. So heroic. Oh, it's well documented, is really cool on it allows you to connect directly to get hope. So you can actually push your files directly from your machine using the heroic cool command line interface. And we will be installing this also which, and it relies on the get libraries which would have installed before on dso You can actually do that. You can actually just synchronize it with an existing git repository on if you have it on guitar, which we probably do by this point, you can actually just comic to get home coming to the repository and have it toasted. So here, I'm just going to connect with Utah. I'm already logged in on. I'm going to just search and find the one that I want the one that we're working on. A pontoon No, is his new site. So I'm just going to connect it on. There it is. Connected, Andi. It is no configured to automatically alot deployments from guitar directly into the hair. Oh, cool container. No. After connecting our repository toe, our heroic ooh container. The next thing you want to do is we can set up automatic deployments if we want meaning. Every time we publish changes to the master branch in our gets of repository, it would automatically update over Hiroko on that would keep it in sync. Or we can do a manual place, understand too quickly. Do Emanuel deploy, Understand to deploy Branch and we'll see some amount off lugging and cortical magic happening where it's actually pulling all the files from Get Tobe on putting here on. Then what I'm going to do is just ensure that deployed a hero who has a green tick on. Then I can click view. Now, if you look at the bottom left corner or others, click it and you can look at the link. You see that the link is whatever the site name is, which is test PHP Trev with hyphens in between dots. Hiroko up dot com on If we look closely received Herro Hello world. And to recall that that is the text that was being printed in our get Hub repository index that PHP page. It's understand to click on this link, which would launch a little bit of middle collected so large it in a new tab on. Then if I look in the index speech, we see that all we're doing is sprinting Hello world on DSO once again, this is where it comes in handy to make sure that your first page is always called Index because heroic would automatically look inside the list off files that have been added to the container on automatically load the index page first. And so that's why we end up with hello world being printed automatically. And then if we wanted to get to the about page, then I would see all of this before links slash a boat, not PHP on. I don't think I have anything printed in my about page, so I get a blank pitch. But essentially, we know how to get our PHP application from our computer to some form off hosting on the Internet on just the verify that this is actually on the Internet. You can go ahead and share this link with a friend just to show them that you have uploaded here first websites that controls over very short on very Cecin tutorial on setting up hair . Oh, cool. You can experiment with Atmore. You have almost infinitely many free spaces are containers that you can spin up. If you want your own website, then you if you wanted, like W. W. Docked my website dot com, as opposed to the up name 0.0.0 dot com. Then you're going to have to end up spending some money, all right, on so heroic who makes it free to post with certain limitations on day. I think at this point it is good enough. First learned the basics. So I hope you had fun on you can feel free to drop me a line if you had any difficulty along the way. 6. How PHP Works: Hey, guys, welcome to this new video. We will be looking at the basics off P H B in this video. On dawn, my screen I am went to start from stretching and we'll go step by step as the whole week and global getting or PHP development started. Now the first thing that we want to do is ensure that we have all our to set up and ready, namely visual studio code on our zump server. If you don't have those, then you can check my previous videos. Where would have walked you through installing them and getting your environment ready. Now, if you have already done so are by the time you have done so, then you can pick up from here on. The first thing that we want to do is start up some so we can just go to our start menu and look for our zump. So that's 6 a.m. pp Next, you want to make sure that Apache end of my SQL, at the very least are running so we can display it start and you can change configurations that will meet them, start automatically. But for now, we'll just leave them as is so Apache and my SQL one started will appear green. One note with Apache is that if you have something else using the Port 80 then you mean get this in art in jazz and it started, but it's unable to be used, so you probably want to just check out if you have maybe Skype or another Web server on your machine. Using Port 80 which ones you will have to start. You have to modify your conflagrations to change their configuration. You can simply click on the button here that says config on, then opened the Apache. Http d that cons on. Then this will launch a text file, which allows you to look for the listen port. They can change that 80 80 or another poor number if you need to. On that would solve your problem. It would kind off introduce another tiny problem. But if you have that, if you don't have that constraint than you're fine and you're good to go and then we can proceed. The next thing you want to do is tow. Create a folder inside off your zump full year zump Web server folder. So what? I'll do is go toe my computer on. Then I will browse toe my installation for the four sump, which, if you didn't change it by default bc zump on that we look inside off ht docks on then all of four Web applications and PHP code and all those nice things will go in here. No, My recommendation is that once you're about to create a new site, you create a new folder. So since this lessons about learning the basics off PH beyond which creates a new folder on , I'm going to call it pH b underscore primer on then every file that is associated with this lesson on by extension in the real world scenario, any website that you be creating you'd put in its own folder on then every file associated with that website would go inside that folder. I know that I have initiated a new website in my Web server. I'm just going to open a visual studio cord and then we can get the party started Now, based on your last activity in visual studio code, it may look a bit different. Maybe had a website open before, and it's still open either way. What we're about to do, We can do together so we can go to file on, then open folder and then that will Alois the boroughs to the folder some which grows to HD Doc Savage here in the favorites already. But then you remember you can just go to your C drive on, find your installation folder for ism on. Then you will find the she docks inside off that folder on then inside this fully of every other folds They want to select the particulary website that you be working on at that time And in this situation we were working on PHP on the score primer. So we select folder on day. Well, I started some configurations and say Don't see you probably wouldn't get that prompt, but anywhere that you were doing before, make sure you save it before you proceed. And then having done that, you see that the Explorer is no showing the empty folder to the left because, well, we created a folder but no files, so we can go ahead and create the first file on. We will call this file on always call this fire index the first file for any PHP application has to be index, even if it is going to be the home page. You don't name it home that PHP you name it. Index, start ESPN by default. They wrote HTML. It really should be PHP. So all files that will be PHP files will have the extension dot PHP so dot html is for regular HTML. You know, you're not doing anything fancy, nothing service. I just straight client side, and that's html. But then for PHP, we have the file extension dot PHP on. Once we create that, we see that we just get a blank file on, then we can fill it with whatever content we need right now, the great thing about Ph. B is that everything that you do in HTML still works in a PHP file. But when we start injecting PHP code, the file extension will kind of negates the use off the court or enable it. So in this case, because we have Doc PHP is a fat extension. We have been able to use off beach be called, but first we'll start off with on HTML page. So in visual studio cold, we can simply type issue McCool on five on that was spin up on issue of five templates called for Us. So this is the skeleton off a national page on duration millipede. You should always have the very minimum the doc type the head on the body on the issue motel. So that's doc type is Schimmel head body on each one is closed, opened and closed at the very minimum. Every Isham api should have that. So once again, if you're using visual studio quantities to spend, that's up by typing Ishmael, call on five and then you will get that beer skeleton very quickly. No one's name this speech. Peace be primer index. So I'm just when the name, It's the name of the website Dash the page. So this is the index speech on this is the first page that we will be using toe, you know, build on top of for PHP application. The next thing that we have here is an issue Matar. So if you're not really committed with HTML or even if you are, I'm just proving to you that HTML works just the same inside off Ph. B. So in this header tag that's playing in each HTML I'm just going to write Hello world and I have enabled in auto save already. So once I see it this file, then I should be able to navigate to it. No, there two ways to never get to this one would be, You know, the regular HTML static. We and the other one will be through using the server. So if I go to the folder where this file is saved and I can just right, click it and say reveal an explorer and that brings up the explorer than I see, I can just double click it Onda. Well, it's appeared to be fire, so it will just open up in the browsers I can't have toe open with on. Well, you can see that this kind of difficult getting the PHP five open with the browser as it would be with a nation off. So what we will do is feed right into how the server expects us to behave, which is by browsing to the server on since the surgeries on our machine weaken Gross, the local host know what I was saying earlier about changing the port number? If you had changed it from 80 Then you would have to say local host colon, whatever other poor to put which if you put 80 80 then you have to broz the local whole school on 80 80. But it is the fault. So we don't have toe specify 80 so against a local host slash. And you kind of see that all the folders that we probably had in our local hosts will be accessible. What we'll be looking for PHP underscore Primer on. Then once you do that by default, it furnishes us with the content in the index page. No. Once again, your first speech should always be called in. It's not home, not landing, but index. So regardless of the content you want on this speech, your first speed should always be index. Because by default, your bro's er your server is going to serve up the contents off the index peach. So, just by browsing to the folder new. Okay, though there's an index spirits. Okay, let me just furnished the contents. All right, So if I change this this text PHP primer on, then I save. And then I refreshed this speech. Then we see that we're actually seeing the content off this speech. Now, once again, we're not browsing to the file path we're not seeing file cool and slash a slash c slash black slash block. We're actually just frozen toward Web Server are some server which is phoned by tapping in local host in the browser on. Then we're going to the specific website folder. So if you named it something else, if you're working on specific website, you just put it in a folder and you bro's local host slash that folder name on, then your index speech will always be the very first thing that is displayed to you. No one's again. Every time that we know works just the same. It's still a PHP page. It's on Isham a page just with a few additions on the addition will come through the PHP tag. So no, that you know that every schimmel tired still works. We can go on and learn a new talk that you would not have learned in html. No, this tug is a PHP target. And to get a piece, Peter, we write our out of the bracket does the same. Then a question mark, then the letters P H p on. Then we we put in all the core that we want. But to end this one, we put twisting Marc Andre Close. All right, so this injects some amount off PHP code into our well html construct. But once again, this court will not work if we're not using a doctor. PHP page. If we're using an issue male page on, I just quickly renamed It's just the Demonstrate. What happens if I rename this Toe Index start issue Mel, the browser or the server was still find this as the first page, but then it will literally print this because it's simple, Doesn't know, holds a process that if I go back to my page and refresh, then well, it's actually ignoring it because it thinks it's attack. So if I put anything in there on, then I refresh. There you go. So it's actually trying to make sense off all of this. It's not making any sense so or file extension needs toe always be PHP file extension on. Then we get code hinting, saying that this is not syntactical current. So if you've done any other programming languages, you know that they're keywords that are required for every language. If not, then that's fine. That's why we're here. So the pH be holding language has specific keywords that when they're typed in inside off these specialized PHP tags, they actually carry out specific actions. Now, what if we wanted to echo hello PHP. So we said, Hello World appear, and I'll just say hello. HTML. So we know that this was Britain with each dimmer. But what if I wanted to say hello? PHP inside the PSP tired so you can always bring the lion. Don't feel that it needs to be in one line on then, inside off the PHP tags the open and close. I'm going to write the word echo. So echo is the PHP way to print to the screen. So if you want to print a sentence, you want to print some block of text began. Just say echo, open and close petition marks on. That's only because I like to open and close. Same time on a semi colon. Every line ends with a semi colon. So once again that's pregnant or EchoStar sorry, which is used to print on. Then we have our quotation marks and then assemble Cola. So in between our quotation march, we type or a text that we would like to print, which is hello, PHP. And then when we go back to our bro's er on, we refresh. Then we see that our HTML has changed because he changed each one to hello html on. Then we see that we're printing Hello. PHP on then. That is how you start pushing content to your page through your PHP tarts. I'm going to add some comments so that I don't lose you along the way. And when you get this so called holding down on the control key and pressing the letters K and C one after the other, then you see that it will generate the comment. Talk for you. So this is basic HTML and then in Ph. B. Our comments will look more like a slash slash or a slash asterisk asterisk slash right on Then that would generate a lawsuit brought multiple lines off comments as we go along so you can use either one so you can have multiple blocks off Ph. B tags, and inside of one time you can have multiple lines off court. So what if I wanted a break point after sold in HTML. We have a tug that is br all right. And that kind of gives you like a speed. It's almost like hitting the enter key inside off inside of a word document. It brings it to the next line. So you have that. What if I wanted to print a construct like this inside off my PHP so I can actually echo html contents directly through the PHP on? All I have to do is type that a scimitar seconds echo be are just cycle. It would look in html on what this will do is generate that tug inside off the overall issue mill could construct or could set up on. Then it will actually render that to the screen. So I'm just going to print another line here. Or better yet, I'm winter prints some block off text here on going to see a second line. So when I print second line or accorded to the additional documents, then we will see that second line comes or in the same line. So what if I need a second line to actually be a second line and not in the same line. So in between these two, I could echo HTM l All right, Andi, off course. Those have to be in quotation marks. So Echo open quotation and the HTML tag that you wish toe have surrendered on. Then you close on. Then let's just try that again. And there we go. So the BR tiger actually creates a space once again. It's like hitting the enter key and banker soft word, and it brings whatever comes out or it's the next life. And that's what happened there. We have our court to print. Hello, PHP Then we breathe the line be srb ire means break on. Then we have or second line. And in that so we actually get that. So that being said inside off the PHP tags, no regular html is a load. If you want html, then you have the echo it directly. Now I'm going to go ahead and create another PHP time. So that's angle bracket question mark the word PHP or the letter speech be and then question mark and close angle brackets. So as I open this, I closest I don't forget to close it. That's a little bit on. Then What I'm going to do in this scenario is create what we call a variable. No, in a variable situation, what happens that we declare some form off storage era? You know, many people call it different things. You can call it a bucket. You can call it a storage area. You're just declaring something that is going to store of value on. Then once that value restored, if you need this value 1/3 for 10th time, you can just call on this very instead off having to type it all the time. So, like, for instance, my name is Trip or Williams somewhere to declare a variable to store my name. And then I'm going to print my name across multiple situations without having to type it each time. So to get a variable in PHP, we just use the dollar sign and then we give it a name. So in this situation, I'm storing my name. So I just call it name and then we see is equal to whatever value we want. So the value I want my name variable to be equal to his my name. Which is true for Williams. No, once you're cold renders one's your page renders, then name is automatically generated somewhere. Somehow. You really don't have to worry about that. Maybe it's on the server what is generated and it's stored somewhere, so any time you need it while you're on that particulate paid. So that means that name here is unique to the index speech. Then you can access name as long as it has been generated. All right, So if I wanted to echo my name, then I could say echo, and then I just see name on. Be sure, toe. Make sure you represent your variable news properly. So if I go back to my piece and I refresh than I see, Trouble or Williams has been echoed to the screen. So I declared the variable name equals trouble Williams. And then I quit it and it's there. But you notice it's still kindof attached to second line, And that's because I need another break in between second estate. This and I can make or break after second I and or can make or break before this echo. The fact is, the echo will always put it in one line unless you try to break it on This is an excellent way to just get that that next line effect. Some just want to echo Ph B break, echo, second line, break on, then echo my name on. Then I will just refresh on their legal. So in case you're wondering how I refresh, I'm pressing F five so you can refresh using this, or you can distress F five on your keyboard. No. What if I wanted to Prince this a sentence and even more so in on each one time for arguments? E. So we already established that we can print our HTML tags directly to the screen so I can see echo and then see each one open the H one. And I'm just going to close it same time because I don't forget to close it later on. And then inside of the each one, I can see my name is Colon. And then this will actually generate it or, you know, um, render on each one time to the screen with the text. My name is their legal. So we're echoing an H one tag with sentence. My name is so what I want after this is actually my name. So then we can do what we call concatenation, which is kind off very structures. I wanted to be a key and very close attention to what I'm about to do on what is required for concatenation is the end, the block off text somewhere attached the variable and then in and then act reattach. Maybe if needs be another block of text. So it's really just about chopping up a string because you have many different sources for the content for this string. So one source for content off the string is is this tug. But in between this tug we need to put in or variable, which contains the name Trevor Williams. All right, So the advantage to this is that if, for argument's sake, I give you this and you wanted to print your any Mr off my name, you can just change it one time here for that name. Very bland anywhere that your echoing name it will echo whatever value you set this still So in this situation, we want to change this block off text from just seeing my name is toe seeing. My name is trouble Williams on maintaining all off that inside off on each one town. So I start off with my name is open the string. Sorry. And I start off with the text I want to echo. And then when I get to a point where I want to inject the takes that I want to add on to what is being echoed on went to end it there. All right, then you see the red lines appearing because they're syntax errors? No. All right. He doesn't know what to do about this, but that's no fear. Because then I use a full stop on. Then I had touched my variable and my variables. Name is name. All right, so that's my variable. And then I used another full stop on. Then I put on my quotation marks. So let's look at that again. I have one block off text on that's character as by on open and close quotation Mark. Right. And sometimes you can you can. You single quotes if you want. I used the, uh, sorry. You can use double course if you want. Are you single quotes? Most times. But you can almost use them interchangeably in more situations in PHP on then. So I open quotation mark. I print my tug or the initial part off my tag. All right, then I inject the content that I want by using the full stop So the full stops is attached . This to this to the what's on the left. And then I put it there. And then the next four Subsys attached this to what is under right and what's on the right is the closing talk for my HTML. Because even though I'm writing Ph. B, I want to make sure that when it renders to the page, the HTML is still syntactical court because the HTML foreign, each one requires you to open on to close on the content where that's up to you. All right, so I'm just opening, adding some content, some static contents. But then I'm adding dynamic content because this variable, the word very well, means subject to change. So the value that is presented by the variable here name is subject to change because I can change this. Like I said from Troare William, still any other block off text and once that is attached, toe what's under left understand to attach its toe. The closing tug for the HTML and then I just end all of this with a semi colon on. Then let's see if my theory works. So what is expected is that when I refresh, this is saying my name is with a little space because I put in speeds here inside the stream. All right, on, then, the name on then Well, end optics. So when I refresh their legal, my name is with a little space on then travel or Williams. All right, so let's try that exercise one more time. So we just printed out our name. I'm going to print my age or well on age, so I'm just demonstrating that these variables we can always declare them when we want on My suggestion is that you try to declare your variables one police. There are times when you won't be able to do that. But try and get them all in one year. So that's kind of organized instead of having your obliquely orations all over the place. So I'm just the clearing name and then I'm going to declare one called age on them once tell you that my age is 21. All right, on, then what? I want to do is echo that my age is 21. Now what I'm going to do is use a keyboard shortcuts. That's control C control V without highlighting with its copy and paste, but without highlighting what I want to copy again. Just select the line and then control C control Vienna duplicates that line without having me highlight what I want a copy on what I'm going to do is just retain this cord on Didn't just change this to my age is on and when to change this variable toe age. All right, so I'm printing old. My name is whatever values in the name variable on by ages, whatever values in the age variable. So if I wanted to change is the 30 to 40 Each time that this page renders whatever the value is, that's what will be displayed. All right, so other state this oats are I can beat that on. Then I will refresh this speech on We should have to each one tags sprinting, travel or Williams And my age is 21. All right. I'm just the drive home The point that I can changes to anything I want at any time If I refresh, I just change it to 31 I'm went to refresh and it should print 31. So once again, whatever the value is off the variable, that is what will be displayed in your peach. Now, with all that being said, if you have been exposed to other programming languages, you probably know that you have different data types and you're very there, there, rather strict on the other types. If not, then that's fine. But the reality is that pH. B on variables, they are not what we call strongly typed, meaning that it can be a text know it can be a number. Leah Terry can be a chart can be a Boolean. It can be almost any data type without you having to specify that it is this type of data type, because right here that nothing has changed in the way I declared the variables. But the values are distinctly different because this is a word on. That's a number in programming. In other programming languages, such violations are off most not a load. So the final thing I want to show you is how the single quotations and the double quotations kind of differ when it comes echoing. So with a single quotation, we have to use our concatenation method to stick in any other bits off information coming from a variable. However, if I wanted to echo this very statement and say echo on, I use double quotation marks than I could still say each one on my name is on. Then, instead of having to end the string and then put in the variable and then rejoined the string, I could just right in my verbal name on just continue typing like it's one big sentence. So I opened my H one tug. I put in the content. I stuck in the verbal and you noticed by the text highlighting kindof shows you that it is not falling in the same category as all the strings. And if I do that up here, if I said name here, you see that determines orange, the oranges, whole visual studio. It shows me that something is is part of the string. So just verify that it is kind of that light blue. It shows me that variable is going to be represented in this PICO statement without my need for the full stops on the concatenation. So that's up to you. That's I'm not seeing one of these rights, and one way is wrong. It's just a much of whole quickly. You can work. And if I refresh this, you see, we get the same results. Top on bottom. So whichever one works for you, that's fine, whichever one you find easier. So I will meet this index file available to you, and you can read through the comments and try and appreciate it. And if anything sticks out to you that you don't understand, feel free to drop me a line on. I will be sure to respond to your worry. 7. IF...ELSE Statements: Hey, guys, welcome to this new video where we'll be looking at if statements in PHP now picking up where we left off with our index speech, we will just want to make our index speech. Like I said, it's the first major London. So it's our landing page. It's our home page. So from here we're going to add a few anchor tags that were alot us to navigates to all the other sub files that we have for this list. So I have added a few courses or a few pages, rather to go alongside each lesson for the score. So for this section of the course will be looking at a raise for and while loops on gifts on switch statements is for if statements. But let me just give you a bigger picture when it comes to programming. We talk about these things called control statements, and there are three types off control statements you have sequence. Then you have selection, and then you have repetition, not necessarily in that order, but the one that's absolute is always sequence, meaning whatever sequence you write, your coding, that's how it will be executed. That's a general idea off the sequence control structure. So just like with printing the speeds, we rode the H one talk first, then the expectations that it should be at the top of the page on everything that we write in the order that we wrote it, it will be executed accordingly. Um, for selection, it means that if you have to make a decision or choice between two options for more options than you have to make a selection or a decision. So that's the next control structure on that is a control structure that the if statement represents. So So I have gonna ahead and set up on H to tag with some list items on these list items are really just on Qatar's still different pages that we're going to create here in your site. So already you can see how you can go both stringing together and each PHP site if you're used to hold to do it with our static. HTML is the same principle with a PHP, though the difference is that each page should be ending with dot PHP. So the next page that we're going to create in our site is the if statement not PHP so back to the Explorer pain. I can just go ahead and create a new file and then I'm going to name it if steam n dot PHP Andi There it is. Created. The next thing I want to do is just bootstrap decisional, five boilerplate templates on going to give this speech off. Name PH B primer, hyphen if statements nine programming there quite a few times. And we would probably want to make a decision. And one easy way would be to say, If somebody passes our fields based on their grade, know that they were doing PHP will carry out every action instead of a PHP talk. So I'm just going to speed up my feet. Be tired from here on every bit off court that I write everything that I want to go on the page. I was due from between these tax No, I'm just going to put on a comment and say, If this were just going to be looking at statements, Onda the first thing that should be printed to the pages on the issue to talk with the words if statements. So we know that whatever we echo should be rendered on our page in cart html According to hole, we wrote it. Now let's try something simple. Let's declare a variable here in our BHP tags and call it greed. And I'm going to assign great to have the value 50 which is generally the past mark in most institutions. Now we want to look at how we could printouts read text if the person has failed or green text if the person has ah passing mark So in Ph. B, the if statement looks something like this were at the word if then we open brace and visual studio is automatically closing it for me because they don't want me to forget to close it later on. If your editor, if you're not using visual studio code on your editor does not do it like this, then make sure you close it first. So open and close have the same time. So you don't forget down the road we're all human on. Then what I do after opening and closing is type the variable so the variable is going to come under scrutiny. And then I know I need to decide. Under what circumstances will I take what action so I have my variable which implicitly has a value on. Then I need to compare it with something so I can make a decision based on that comparison in this situation, we did say that if the pastor mark is 50 than anything over that that are over is a pass on anything that are with anything under is a failure. So I'm going to see if the variable greed has a value that is greater than on. We're using the greater than sign or equal by using the equal sign and then I give a comparable value. So inside of these braces, I'm going to see if said variable is needs this condition with this value, right? So the condition is greater than our equal toe. Some value, then Well, there is no word then it is nothing PHP So we open and close curly braces this time. All right, I understand To break a line in between. So we have the parentheses, a regular brackets that we all right and used to love in the English language on Then we have the curly braces, which will we use less frequently in English writing, but very frequently in cording. So we open the curly breeze on. Then inside off those curly braces, we put whatever actions you want to carry out. So I'm just going to keep it simple right now. And I'm going to see Echo on which echo on each three tag. And I went to see you have passed. All right, so we're not get up setting the colors. I'm just echoing something simple just to demonstrate this. If l selection. So we have if under condition and this condition will contain some variable or some value on the left, Some comparison operator and comparison operators can be on and destroyed them. It can be equal, equal meaning equivalent. It can be greater than it can be less than it can be greater than or equal. Well, I really know which one is which one is greater than our list done. But the fact is, you can peer them. So whichever one you are using, you can pair with an equal sign. All right, so you can look if it's exactly the same. And I think in peach we have, ah, triple equal science. Or just put that here so that we can compare if they're the same value and data type. This one looks at the value, um, if it's created, unless than or listen and equal greater than unequal. So if this condition is true, if if this comparison is the one that works because Grady's greater than or equal to 50 then we were echo the sentence you have passed on. Then we can see else Teoh given alternative to see meaning. If this is true, then it will do that. If this is not true, then do with this. So it's just like if it is raining, I'll go outside. Otherwise I'll stay inside. So you know, this would be that one condition that determines what you will do. And if that condition does the whole true, then you do something else. That's what if else really means so here I would just equal you have field. So just stop it this good, you know, work smarter, not harder. I'll see you have failed. Now let's bro's to this page and see what the all come off this bit of court. It's I'm just going to go back to my browser where they have my index speech and I'm going to refresh with other means. Some changes since the start of this video. And here we see we have all of those links as we all lined in the index speech earlier on one off them. Is that your statements? I can just click this Andi it Willbros the if statement page and noticed the change in the link. It goes from Peacekeeper Hammer toe PHP premise slash statement at PHP on. Then once we land on that page, we see you have passed. Now, if I change this greed toe 30 then we should see something as being printed. So I changed the grades of 30 Seem that change. Refresh on Dennis telling me you have field. All right, so we can tell that it is making a decision. It is comparing whatever values inside off this variable with this variable to see if it is greater than our equal. If it is, then it prints You are passed on. If it is not, then it says your field. No, We said we wanted it to print in red or green, so I'm just going to add some CSS right here. Inside this tug on, I'm going to see style equals. And then if, in case you're not necessarily familiar with CSS, this is what you call in Lyon CSS. Where you use the style attributes. It works in regular html. So if I wanted to do that, I could say H three, open off. Sorry, I can't do that inside PSP Tired. Let me do that above it's three and then open and close it street on. Then if I wanted to meet this red, I would just born to the issue type process peace between the tag name and the angle bracket on in type the attribute style on then make it equal toe some value, some selector and value. Pierre. So the selector Val appear here for color would be literally color. Andi. I would see red or green or blue just to keep it simple. So the same way I can construct this in regular HTML. I can actually echo that in the pH piece, understands a copy. This part, since that's a part of old standing on, I'm going to paste it here on notice. I can use the double quotation marks inside of the single quotation marks, but if you miss that opened new use single quotation marks here than it can cause problems . And you have to end of contract in eating and complicating relatively simple situation. So just be careful. If you open with single courts and you need courts inside, use double courts and vice versa. So I'm going to add that so this so this should prints while this is print green. Since you have passed on, if you have failed, then it will print the same each three times in a red. And then let's try that again, someone to refresh this speech on. We're still on the failure value. So you see that it has turned to read on. Then if I up this 80 which is greater than or equal to 50 then it should print in green. All right, so that is whole. You know, you're on the websites and you see that dynamism between whatever you put in and the color scheme other, you get back on the visual cues. This is all they're doing. They're saying, if you put in a certain value that we don't like or we don't approve off, then display her it text. If we approve of it in this play green text. That's all it saying. If some condition else. Now, if we had three conditions, let's say we had three tiers off greeting. We can see if then else are just right, if else if Onda else. All right. So what if you had three or more conditions that you needed to compere? Like, for instance, yet maybe you wanted to print all the little great based on the greed that a person thought . So I can really clear greed right here. Once again, these variables are not strong, the types, so I can easily declare it as a string this time. So it's a number appear, and it's a string down here and once again, sequence rules. So it starts off as a number than it does all of these operations as a number. But then once he gets here, realize oh, my master wants me to change so a letter. So it becomes a letter and then we start doing some operations. Don't here with it as a letter. No, this is not necessarily recommended. I'm just doing this, for example. Purposes. What PHP is that flexible? Now let's get to work. So we will say if on that sin taxes pretty much assumed it, sometimes it doesn't make sense. You asked why you have to put in the braces. Just know that if you don't, it doesn't work. That's just the rule that the programming language abides by. So we say, If open breeze and then or condition, which is greed on, Let's see if it is equivalent to an A, then we print. And then there are times when if you're doing one line after the statement, they don't need your court, your curly braces. I recommend them, though, because if you ex intent expanded cold later on the day, I mean, they're already there, right? So no harm, no fault. So if greed is equivalent to a then I want to Prince Oh, uh, on hte to targ on going to say you are a super star exclamation close. All right, we'll come back and deal with the colors later on. So then we close that and remember, we end every line with a semi colon. If you don't, then you end up with some problems with some curly braces. Are some red lion. Sorry on if I refresh this speeds, then you will tell you they have a syntax area won't necessarily spell over your leaving off. A similar problem on this nine body will just express See that you have an error. So let's remember your cynical lines that remember the full of the rules off the programming language. So I can say if the great is equivalent to a then your print that you're a superstar else If on then we specify another condition which I could understand to copy this condition, it could be else. If the greed is equivalent to be, then we can still ah, motive e the person someone to see. Echo. Sorry, Echo Andi. Which Queen? International Tug It's too this time again. And see you did well, exclamation side. So we're still encouraging the person. But then, if they got to see or any greed below that on then off course, these conditions are based on what values you know will be there. Because if the person got any plus than the else would not detect that Oh, it's near and s so you know, you have to call it according to your context. If I'm just in a B c d e f I know that there's no a plus R B minus or anything that then I can do this. But then, if I wanted to send the same message for different tiers than I have to add on operators like Andi and then see another conditions, I could see Onda greed or I can see your other or Sorry, agreed is equivalent to another value. Then it will say, If it is this value or it is that value, then do this all right, so you don't for your context, you'll be very particulary bolt hole your writer, if else if else statements but every else if else demand must end with an else because else is the catch our it means that if nothing much is these two conditions, then it most much just catch it on. Do something. All right, So then if anybody got a C in this class after this good tutelage, then we will say you have failed. All right, Andi, just let them know nice and gently that didn't pass. The force aren't so. They either got an a a B on the past or they field on. Then if I run this scored with the A. Then I should see this refresh. You are a superstar. All right. If I change the variables value to be on rerun, see if under under your on, then I will see a different message on just to seem. If I put anything that's not an a r B, then it is winter print that you have field right and then just add a bit off color to it. We can just copy the styles from above. So you are superstar Prince in nice screen, Andi, I just used that same stock is the same quote. It's just the value that changes. So if you have, if you did well, you get blue text on, then if you fail, then you get read text. All right, So if you are a superstar, I get green. If you did well, you get blue And then if you fail, you get rid and then I can just reprint that so you feel should print with red. All right, then, if we can go ahead and experiment and change the values and expand the list toe a cone for more than one more than three sorry values based on the grading scheme that maybe you pass through the college. You went toe with Andi. Then you will see whole dynamic. This if else can make your core. All right. Thanks for sticking around. And if you have any difficulties, are eloquent stuns. Feel free to drop me a line out of I'll be sure to reach out and help. 8. FOR Loops: Hey, guys, In this video, we will be looking at the four loop in PHP. First thing I want to do is create the file for the four. Lupin are already established folder for this website, so I'll just go ahead and click new file and ride for luke dot PHP. Next, I will generate my issue off of template on, then go ahead and set the title to be Ph. B. Primer. I've been for Luke. No conceptual. Therefore, loop is what we call a counter controlled loop, meaning it does something for a certain and a set number off times is usually used when you know exactly home. Anytime something needs to happen on DSO, use a for loop to repeat it for that exact number off times as long as you get your permit is right. All right, so this construct is available in any programming language on it is pretty cool in PHP because the lows it's a kind of dynamic, a legendary it things based on certain variables. Before we can write any Ph. B chord, we know that we should put in a header tied to see which page we're on some disporting this from the suit statements page on. I'm just going to right on each one times at the top of the page to see that we're on the four loops. Peach. All right, Next up, we're going to initialize our PHP tags. Andi, inside our ties is where we will be able to write our pH. Please understand. To add a comment and remember, comments don't get executed. That's why they're handed there just there for documentation purposes, so that when you look at this court file, you have an idea off. What you know comes afterwards. It's always a good idea to write comments in your court. Now, it's only for other people who might really record but also for yourself, because you may have taken a break and then come back and you need to pick up where you left off. Sir, Comment always helps with that. No, the syntax for a four loop is you write the word for then you open on close your braces, your part indices, and then inside of these parent disease, you declare a variable and someone to declare a fair man. I'm going to call it coolant. All right, Andi. Well based on Hawaiian named the Verbal. You could call his verbal anything, but I'm naming a cone because that's exactly what we wanted to do. We wanted to keep ConEd off the number of times this query will execute on. Then I'm going to have a condition, meaning under what conditions should I stop executing? So here I can see that the condition under which I should stop repeating answer in action or this loop should stop repeating the particulate. Action is, I wanted to stop under the condition that won't is less than let's see 10. All right, so this should run for 10 times. Why? Because it's starting off with a value of zero. And then it should change one, then two, then three, then four, then five. So once it hits the condition where count is no longer less than 10 meaning it's when it's 90 will run than when this comes up to be 10 then 10 is no longer less than 10. Then you will x exit that loop. All right, so if you wanted to run for 11 times are for 20 times, you would say it is next than 20. All right, on be sure that you're sitting this zero. If you said this is the one. I mean, it was still work. But then you have to be keen to know that if it starts off at one, then you're missing one iteration. Because when it starts at zero, it does an iteration with the value zero. Then it goes to one, then two, then three. So if you really wanted to run for 10 or 20 times, then you need to start at zero, and then you can see run until you are less than 10. So once it violates the fact that's less than 10 it will exit on. Then, after that, what we need to do is to let it know that it needs to count. So we just write the variable and then we say, plus plus All right, so plus, plus is ah, post incremental, Which means that he will run with the value it has. No. And then when the loop is finished doing its thing, it comes back and it says, Okay, check the Gandhi son, I'm still zero. Okay, that school count upto one. All right, well, it actually says count upto one on, then check if you're if the condition is still hard. So that's what happens right there. Now moving on. The next thing we need is our curly brace, so you'll see this curly brace up hearing a lot in PHP andan other programming languages. So just get used to it that once you have a construct that it's an if statement, a suit statement A for loop while Luca on many other constructs, you just have to put your cord for that Construct inside off open and close curly breezes. Now what if we wanted to print to the screen 10 times? Hi, Hello, World. Someone to write Echo on. I'm going to print on going to put this in a pitak this time and I'm going to say hello worlds and then close the Peter. So I want this to prints for 10 times the text Hello world so that for Luke is going to start off at zero on run 10 times, and each time it runs is going to do whatever is inside the body to get done. Now I'm going back to my home page, and then I'm going to click the page for four loop and Then we see here that we have 10 paragraph tugs for the text. Hello world and we didn't have to do anything. We just wrote a four loop and we Rotella or hello World once on. But we got 10 lines, and that's a poor off a loop. Because then we can dynamically generate HTML tags or whatever content we need as many times as we need it on that particulate peach. Now let's try something else. What if I wanted to print the value of cone someone to do another example? So I'm just going to rewrite this four loop, and I'm going to do it from scratch for on. Please know that the variable that you declare in this is within what we call the scope. So if you would call a variable Collins up here, current only exists for as long as this. This loop runs once it exits that loop, meaning it's finished with repeating itself. That variable no longer exists. All right, so I'm going to reuse that very because I know I won't have any conflict because it stopped existing. Bite it. By the time it hits this next loop on, I'm going to initialize it to zero. I'm went to do the same condition. Andi, I am going to cold plus plus on. Then what I want to do in this for a loop is actually print the value each time it is run. So I want to print to the screen or to the ancient A PGE went to the bro's er the value off cones. And to accomplish that, we know that echo is what we use the print on. I'm going to use interpolation, someone to use my double quotation marks, and I'm just ending my lines. I don't forget to do it later on. I'm going to see the cones is colon. And then I'm just going toe reference my variable called cones. So that's interpolation at work. We looked at concatenation earlier on. We realize that while it can work with the double quotes, it's absolutely necessary with the single courts on def. Where is in the double course? You don't have toe have to use concatenation off course. This depends on your version off ph. B. So if it doesn't work, then you can upgrade or if you hold breeding is not an option. You can always concoction. Eat. Now let's see what this does. So when I refresh the Peter should see Hello world 10 times. Yes, Andi. I should also see our countdown, Our count up for the tech. So you see here it's echoing the cones is zero. The cones is one, but and it's all in one line because in a previous video we would have established that we probably want to break line between our eco statements. So first them wins a putz. This So what happens is that when you print the static text like that, it will print in one line. All right, But then, naturally, in html, what happens is that a P tug comes with its all what we call putting. So it has its own spacing from the top and the bottom, so the P times wouldn't come in one line. So look at the difference. Were echoing Pitak, sell a world. They all come in their own line. When we echo the static text, it all comes in one line. So it's a remedy that we could echo a break tag are we could just put it in the appropriate time because, really, actually, you don't want to be printing the static text toe on HTML. Pete, I always recommend that you anything you do, you put it inside off some form of tug so that the bro's air can handle it a certain way. All right, so when I refresh this than the behavior between the hello world on the counting is the same because they're both p tags. Andi. Further to that, we also see way are printing all the cone so we see where it starts with want with zero goes toe one through nine. There's No. 10 because once again, once it hits the value, 10 on 10 is no longer less than 10. Then it will exit that look on. That's pretty much it for the four look. Go ahead an experiment. See what you can generate for as many times as you need to generate it on the Web page at some comments and share this court file with u Onda. See you later 9. WHILE AND DO...WHILE Loops: Hey, guys, Welcome back in this video we will be looking at while loops on do y lives in PHP. So to speak things off, we will start by creating a new file and we will call this one the while Do while Duke. You know, originally I would have split them into two. So I'm just going to actually merged these two this link in tow one. So it's while do while you GHB and someone to remove that reference here. And then I went to see a sample while slash schools. While now in our previous exercise, you would have looked at the four loop on before Luke. We would have characterized as a counter control, because what it does is cones to a certain value and each time it checks. If that value has exceeded another value on DSO it besides the week or whether it continues or it exits, the four loop is called a counter control group. The wild and do I loops over are called condition control loops because real eventually they aren't commenting there and concern about counting. What they're concerned with is if a certain value meets a specific criteria. Andi are criterion and then it makes a decision. So just hop on over, toe over while do I file and we will do over html template and we will give or document of cart time title, Which would be do slash. Sorry, while slash two While Luke Oops. Now I've prepped the page with to each one times one for the while, loop section and one for the do While section on DSO we will be looking at them in separate court blocks, but then we'll see how similar there and why I decided to put them all in one less. So let's start with our while. The first thing we need is our PHP tag on, then the syntax for a while loop is that we see the word while on. Then we open our parentheses and you would see that that's a pattern. Every time you're going to do a loop or a certain kind of control structures, you just have to have a parent disease. Don't really that rule, and you won't have a hard time. So while kind in what we need inside of these parentheses would be a condition, so the condition could be while some variable. That C grade is less than 10. And then this will be my condition. No, it would kind off look very similar to the wild group. But the difference is that there's nothing else that goes inside of these parentheses. It's all their condition, and the condition once again is comparing. Some value are variable on the left to some value or even variable on the right on. This is the comparison tool in this case we're looking at. It is less than it could be equal to equal be equal or greater than etcetera, etcetera. So I'm just doing a while. This condition obtains. Then curly braces do some action. All right, so I'm just going to declare my variable. And please note if you try to reference a variable without first declaring it, that will be a problem. So I'm going to just initialize it toe zero and then we will see wild greed is less than 10 . We want toe a core, maybe a P tag seeing I am less than 10. All right, so just put a P tag here on I am this than 10 exclamations I fired and then closed. My feet are So what this is expected to do is do this action. While this con tradition is not true, meaning as llamas, greed is less than 10 than it will continuously do this. Now you will notice that when I broached this page, it will generate infinitely many off these eco statements. And that would be because we will be locked being what we call on in finite loop arts on infinite Loop comes about because there is no condition, toe or this condition would never get met because I'm not doing anything degree. Great is good, is zero. I'm not changing the value of greed anywhere, and so greed will always be zero so great will always be less than 10 meaning this will always print. So that's one of the dangers. With a while loop. You can run into that kind off error. No. If I tried to broach this speech, I can expect the problem because the while loop will run almost indefinitely well, very indefinitely, until at least the machine or the server runs out of resource is toe. Perform the action on. So here we have it. It's less than 10 and you can see that the machine is really struggling because I'm getting that loading sign. And if you look about the scroll bar, it's just continues the printing because great is just not ever going to be equal to 10. So understand, To close this quickly on, then I'm going to rectify the situation. So what we want is to ensure that our condition will get met. If it doesn't, we are in an in finite Luke. Somebody's going to leave a comment here and see in finite loop so that you know exactly what is happening there. But then I'm going to commend this haute, and then I'm going to go below that, and I'm going to write another while loop. That would probably actually, you know, exit at some point someone to repeat this. I don't want to say agreed less than 10 on, then inside this and want to carry on my action just the same. Some almost rating the same Luke, except I'm actually going to deliberately, on each run, change the value off grade. All right, so that is another thing you can actually kind off similarly, it account. All right, but then that is a manual step. Once again. This is a condition control loop, so this does not facilitate the use off any counters. But then, for all purposes, we can always Conant. Andi changed agreed up that the value off great or whatever method you want to use you can use that method to change the value off greed. Some just been to see greed plus Plus, as we saw in a For Loop, the plus plus is like an auto incremental er. So what will happen is that great starts off zero. Then it hits the wire loop on. Then this condition holds true because agreed is Liston's Europe. But the lesson 10. Then it echoes that on. Then it increments, and then it hits here and comes back and checks the condition again. Is greed less than 10? Greed at that point would be one, so it's still less than 10. So it goes again and there's the same thing, and over and over and over until greed eventually becomes 10 at which 100.10 is no longer less than 10. 10 is equal to turn, not less than so. Then it would exit the loop, so I'm just going to echo a quick statement here so that we know when it exits the loop. Andi, see exit loop. All right. And so I'm going toe bro's to this speech again. So when I click on the wild a while I see that it ran 123456789 10 times on. Then it exited. So I did exactly what we expected because once it hit that condition no longer being true. Then it exited. I also know that we've addressed the while loop Onda. What we call the while is a precondition, meaning it checks the condition before it does an action. Which means if I started off with the value off greed being 10 on, then I refreshed that particulate page. I would never, ever get into loop because guess what? The condition and it realized that well, great is already 10. So clearly I can't do anything here. So it just went on to the next available statements fired, so we called it a precondition. Look, now, if you're in a situation where you need something to be done, at least ones, but then repeated, if a condition is not met, then we have our do while which is called a post condition group. Someone to initialize another piece B block here. And as I said, you can initialize them almost as many times as you need to have force. Use your discretion and your, you know, creativity on your efficiency, of course. But when we initialize this block, what we want to do is say do and then we open our curly braces. So do on then, inside the credit braces. We know by know we always put whatever it is that the action should be for that particular control structure. So we say, Do open carry breeze on that we put in any action. So I'm just going toe prince here. Andi, I'm going to say I am. Do I look just so? We know exactly what's being printed fire. So I am doing well. But you see that there's a little red squiggly line under this because we're not finished. What we need to do after we have done this, at least ones is then check if the condition obtains so I can reuse the same condition in the same syntax where opened the breeze and then I see agreed. Less than 10 and then I end with a semi colon. I'm sorry, I'm missing out the keyword. I did say that it is. Do while So I have to say do this while conditions. Apologies. So we do on action while the conditions. So what will happen once again is that it will blow it at least once. So I'm going to set this to zero So great zero. So the expectation is that it will do this while the greed is less than 10. And once again, if we don't count, then we'll run into that in finite loop situation. So to avoid that, I'm just going to deliberately cheers of value off grade each time. So I'm just going to do that at the end off the actions and I morph this value so that eventually it will meet the condition. So you don't want to do that morphing in the middle off your actions. So let me just refresh this speech and see what happens under our do while loop section. So we reset, agreed to zero, and you can see that greed is is serving multiple purposes. So that's one of the advantages using variables you can set it once and then use it multiple times Authority records. So because it zero or while loop is active once again andare do while has done this action at least once. Now the reason for doing it at least once is the fact that by the time this one variable has finished with a while loop remember that it would have incremental up to 10. So when it hits the do while loop, then its value is already 10 on DSO. It did this at least once. Then this went up to 11 because it was already 10 by the end of the for the while loop Sorry on DSO when it hit the condition this was 11. Andi, that's 10. So that does not hold true. So it would have exited so once again to do I will do everything at least once on, then check the condition and that's why we call it a post condition some distant at that comments right above the do while called block and say that it is a post condition loop. So what I'm going to do just to make sure that we get the most out off our do a loop here is in the cold block for the do. While I'm going to reset greed to be zero. You can always set the value off your variable whenever you want. Yes, you said it wants up here, but I wanted to be something else thrown here. So I'm sitting it again. Andi. Then I will refresh my page on. What will happen is that the while loop gets the value zero and it loops and loops and loops until it's 10 on. Then the door while resets it 20 on. Then it will run. 123456789 10 times. Also right on. We could have put something outside to, say exit group, and then we would know when it actually finished executing. So the story fresh on There we go. Exit. Look. All right, so that's pretty much it for the while and the while. Oops. You just need to know when to use which one. If you need something done at least once you use your while. If not to use your while on otherwise, if you need toe, keep ConEd off the number off times. Definitely. Like you definitely know how many times something should run then. Therefore, Luke is probably pissed so you can use them at your discretion. 10. Arrays: Hey, guys, welcome back in this video we will be looking at Harry's in PHP. Know, up until this point, we have been looking at variables, which we defined as storage spaces for values or some form of content such that we didn't have toe retyped this content over and over again. No variable is more like a singular space, meaning that if you change the value off the variable one time, you can only store one value at the time, so to speak. No honoree is like an extension of a variable where we can store multiple values inside off one variable like structure not to get things started off. As usual, we create a new file. I read out Ph. B has We already have the link there, and I'm just going to go ahead and create that file, and then we go ahead and spin up over. It's enough templates. Then we go ahead and change the title to what we know is the standard PHP primer Dash Cherries. And then we put in over. Each one tugs for our arrays notification, and then we get our hands dirty. No, I did start off this. Listen by seeing. Sorry, I did start off by saying that we have a new plan stroke call under called Honoree, which is similar toe available. Now we've seen variables where we declare maybe gnome and then we could say Z put the three . But what if you needed to store more than one numbers and you didn't want tohave a variable her number? Because if we wanted 10 numbers and would have to probably start seeing someone numb to number three number four and storing them all in each variable. But then Honoria lows is to use one variable on store, many values. So I'm going to declare. So I'm going to just commit this and say, this is variable on. Then underneath that I'm going to I commend Insee and this is on Ari on. Then I'm with Dick Urinary by seeing numbers. So it looks just like a diarrhea declaration. Are variable exploration initially, But then we see equals ary and then open parentheses. And then inside these parentheses, we add as many values as we will want to. So I did say numbers. So I'm with add each number on it is comma separated someone to add numbers one through 10 . And so what we have here is an ary off numbers one through 10. All right, so we can have an array of values and this is what we call a homogeneous ari, meaning only one type is being stored. Now, in most programming languages, that is the norm. But in PHP, they actually Lohse storm word or more than one types off values are types off data. So we know we have string for text. We have numbers on, we have, well decimal places. Other programming languages are more strict. But in PHP you can store almost any you know, combination if you want. So in this case, we're only storing numerals, so I'm calling it Ah, homogeneous and homogeneous area. So know that we have established injury. What if we only wanted to print one off the numbers at a time? No. An array is numbered from zero toe end and being the number off values in that area. So, in this is your son the subscript as recall. It would be zero for the number one one for the number two etcetera. So at this point is always minus one. But the fact is that regardless of the data type or whatever it is you're storing incendiary, the 1st 1 is always zero on the last one is always in minus one where and is the total number off values in, said Ari. So if I wanted to print anyone off these values just the value of not all of the values I could echo and I would call my area, which is called numbers. So it's the same construct as printing variable, except I have multiple values. So I want to specify the value I want. Then I have to know which number it is in the ari. So if I wanted to print the number six since we're starting from zero, it would be 012345 So if I prints the subscript five and I get the substrate by using my square brackets next to the name off my ar e. So my ari is numbers, so I puts echo numbers and then open and close square brackets and inside off the square brackets. I put the number off the Ari that I want to print, right, so that's a subscript. That's a location. The position. However you need to term it. It just means that I can find the value. I'm interested in this position in the Ari on I remember. Once again, it starts at zero and ends that in minus one. So I want to print the number six. It would be 123456 minus one because this was really zero. All right, So if I do that and then I rose to the page, then we see where I am printing the value six, which is indeed in the fifth position off my ary because I started counting at zero. No, I can repeat this with any other subscript that's I want some just into a cool another lion . And this time I'm going to put it in a Peter, someone to just put the variable or the reference to the area and subscript inside off quotation marks so that I can get that interpolation on. I'm going to put it in a p tag on going to change the subscript I want to print the last value. So, like, I cities in minus one. So I have 10 items. So 10 being in in minus one would be nine on. Then if I refresh this, I see I have six being printed first, and then the number 10 be imprinted after On the other cool things you can do with honoree is to find the size. So let's just say I wanted to know how many elements are in my area, and I'm going to put in some other random values, some just expanding this area. Well, that wasn't very wise off me. Eso I'm just but expanded my fingers hit a few keys that they shouldn't have. I mean, he talked common twice on. I want to get rid of that extra comma on. So at this point, I didn't call until many key tops I made. I just want to know how many values are in this, Ari. So I'm just going to echo, and I'm going to use double quotation marks. Second is use my interpolation on. Then I went to see Pete. Doug, hurry. Numbers is size on. I can just say something like cones. Okay, well, this won't actually work, so I just realized this won't work because currencies are functioning. Interpolation really only works with actual variable someone to have to do this up it differently. So I'm going to please close by Peter Hug. Just a seam on. Then I'm going to tee this oats because this is the function that gets the size off. Very so I'm just into the clear of Errol because I can declare these whenever I want. And I'm going to say size is equal toe on. Then I'm calling the function some peace be function called cones on dime passing in my area as a parameter on. What will happen is that this function is going to go ahead and count all of the's whatever number that is on, then one whenever it's finished, that operation is going to assign it toe the terrible size. So when I want to print that are e numbers his size, then I can just print the value that comes from the variable size. And so when I refresh once again, then I see Oh my, I have a little air here, so we're getting on air of boats on undefined verbal, and that's because I'm seeing number here. So that's good. We have our first PHP era were showing us that we have some unidentified variable online 23 so we know exactly where to look on what we are looking for. So the arrow is that have the areas numbers, and I'm referencing number. So I just Adam s there. Fix that Onda their regal. So no, I have 20 values inside my Ari. Andi, if you look at this closely, remember that we started off with this being 10. All right? No, it's 101 Why is it one on one? Because what? I change the 10 to 101 So it's just looking in position five and bringing back whatever value it sees that. So this ari subscript thing works? No. What if I wanted to print out everything in this hurry ever value without actually writing the sub scripts manually. So if it was five, then maybe inbred Emmanuel before maybe 10. Okay, you could be a three, But then I have 20 and I really don't want to sit down and write echo numbers. One echoes numbers to world starting from zero open till while 19. So I can actually use a loop. And this is where we start seeing a whole hour Loops are actually useful, and I can say four and clear some cold winter. Andi initialize it zero Then I see cones is less than and we just got the size off the area So I can see where the cone starting from. Zero which we know is the initial subscript off any area where we can do something until it exceeds the size off the area. We just got the size of very so we can just see cones is less than size on then hones thus press on then for the action. What we want to do is a core and then once used my interpretation once again and we want to equal the variable numbers. But here's the twist I am not when the hard cord, the subscript like I did here because here I hard coded five and here I hard coded night. So those are never going to change. But what I want this to do is dynamically go through this Hurry from the first to the last on present me the value so I can actually use a variable here in the sub scripts because variable can contain ah, comparable value. All right, so I'm just going to inject the cold winter which is the variable cone threat here as the subscript because it starts from zero and it goes toe one, then two, then three until it is no longer less than the entire size off theory. And that's where you start putting the pieces together. All right, so when I do this, it will just echo, echo, echo until it finishes the four loop Onda. By that time, we should have printed out everything inside off very someone to put these in P tags. Just make sure that they render absolutely, perfectly to over a Schimmel. And then we're going toe. Refresh this speech, and then we see it's printing 123456 through nine. And then we get start getting those crazy numbers that I had entered at some point. So the fact is, using a foreigner, we can easily Trevor's and print old. What is in this specialized storage construct called an hurry 11. String Manipulation Functions: Hey, guys, Welcome back in this video we will be looking at string manipulations with GHB. Now, as usual, the first thing we do is to create a link in our index speech that will speak to our stream manipulations. I'm just going to duplicate that and I'm just call it String My nip that dhb andi just rename all this text. Now that I have the link open, Ito create the page that this will never get to. So I go over and create a new documents. Call it string my nip, not PHP on. Then I go ahead and spring up my Isham of five boiler pleats. So after doing all that and changing my tattle, let's get straight into the fund. So firstly, we're doing ph b. So we have to use our PHP tags on. Then I'm going to declare two variables here and remember that to declare very But we just need a dollar sign and we give it a name. So we see Frieze one is going to be equal toe and I wanted to be a string on this time I'm going to use double quotation marks on day. I'm going to see um, let's see students who came late. All right, on then I'm going to declare another variable on. I'm going to call. It frees two on. Then this one is going to see in class, comma stand with rock, all right to random sentences that are really mean anything but essentially. But I know we should know how to be clear variables and assign values to them on. We know how to echo variables to our screen. So if I wanted to print out what is being expressed by these freezes, I can just see equal freeze one, all right. When then? That would actually just prints that statement here for his one for his one toe the screen on. Likewise, I can echo freeze, too. All right, So the end result off my echoing these two statements is that they're printed line by line right students who came in well, who came late on. Then you notice later in our kind of joint because there's no space because the strings were kind off. What? I didn't put us peace in either one. I should have either put a space here or a speech here for the echo statements to do that. But you notice once again that they printed out in one line and we'll really ventilated that. It's best to print the tug that they should be printed in. But today we just want to look at string manipulation. So I just keep it rather simple for no. All right, so the first thing I want to bring across is a thing called concatenation, which is actually the joining off two strings. So let's say I wanted to join them together, but we just did that right. We just joined them on. Do you see that they are there. But then there is no space here on what if we wanted to inject something else in between the text that is already in the tool Variables. So concatenation actually alos us toe put blocks off string together. Whether it's a string variable or it is stuffed extreme meaning, I am declaring just opening quotation marks and typing strings. If I want to put them together, we call the concatenation on In PHP, we use a full stop to con Katyn eat. So if I say echo, freeze one dot and then freeze too. Then I get the same net effect. When I refresh, I just change the court and I'm just refreshing the page and you see that it's the same text. Alright, But then I need a space. I'm not going to modify these two. I don't know if these two should or should not have a space. I'm not going to put one there, but I know I wanted printed with a space in between. So what I'm going to do is say docked. And then I went toe open quotation marks and then put in my old static string which in this case can be a space on. Then I use another dot So each time I use a dot I'm actually joining a string toe, another strings. In other words, I'm drying the string that is in freeze one which is student who came in late and then I'm joining that on toe stream that I only put a space in. And then I'm joining all off this further onto another bitter string called, which is found in freeze to. So when I refresh this, I will see it printed with that space. All right, so, by extension, if I wanted to add more to that sentence steel into Kim late. And then what if I wanted to specify on? Then I said, maybe comma. And then I said named. Sorry. Then I said named too funny. Come on. All right. So what this is going to do is see Join on Freeze One, which is student who came late on. Then join on the comma named Tiffany on in comma. So everything inside of the static string will be joined onto this to the right of this onto the left off this. So when I refresh that sentence, then it should include all of that, right? And then you notice I don't have a space here, so I can just go back and edit that string on, say, comma space. Too funny. All right. I know when I refresh everything. Looks like Lisa fairly properly formed statement. All right. Of course, Grammatical. It may be encouraged, but at the end of the day, I just want us to appreciate how we can go about doing what we call concatenation. Now moving on another cool feature that it PHP as they expose certain built in functions that closed toe set. If we want let us to be upper case or lower case. All right, so I'm going toe creates a variable and call it name on. I'm going to put my name in there. So my name is Tre four. Williams will notice. I'm writing it all in lower case fire. No. If I wanted truffle tremor for Williams to be printed with uppercase letters at least the first letter, then I would do something like this. So here I haven't echo statement. I'm just echoing descendants properties first letter. So I want the first letter in this variable to have on properties letter so that the first letter in this variable is D. All right, Steven Lee Strobel Williams. That's the first letter in that entire variable. So if I want to that upper case, then I would use that function we can see here. While this is not printing out as we desire on once again, that's because remember, the echo does not break line automatically. So tell Do is just include an echo on. Put a VR tag right here so that we have that breed client after this concatenation exercise . All right, so once again, let me just We do that on. There we go. So opportunities first letter on we're up a casing t in the variable name. All right, so just another change. I just remember that we should start off with our each one talked at the top toe indicate which beach were on. So apologists were skipping that earlier. But essentially, our there are fun, Sean, for that is you see first name on notice. I'm still using a concatenation. I'm echoing a static string here. Yes, I use single court, so I'm just doing it. I can use single courts are double courts on. We set up our case for us letters. So the demonstration is that we are Oprah casing. You see, a guest means upper caisse, and if you hover over it and you have the requisite, um, extension installed and you get a bit off explanation as to what that function does on it takes some string as its parliament. Also, I'm passing the name, which is a string variable on. Then it is upper casing. The first letter in that string on then I'm further concoction a ting a br tug. All right, so the concatenation works with functions as long As you're expecting a string, you can see static string, concatenation it onto the result off this function call which should be a string, which would be the the transformed upper of the upper case of the first letter of this string. That's what this function would return, which is also a string say, continent, that onto this sentence on, then I'm further concoction eating a br tab. All right, on then. What if I wanted each word toe? Have properties? Parents understand To duplicate this on. I'm going to see properties first letter off each word. All right, so this eco statement is going to print out, or at least I'm going to change the function that is being used here. So you have. You see first. And you have you see words. All right, So you see words. Actually, upper case is the Were each word phone in the string. So that's one word. It's open cases. The first letter off that word, this is another word. It open cases, that one. So if I put in for his one, then I would get a capital s capital W capital C capital L. If I did this one it would be capital I capital this year. Century center. So because I'm doing me, I expect to get a capital T on a capital W. And when I review the results of that, there's my each one tug on die review the results. I'm seeing Trib or Williams fired on. I'm seeing exactly what I expect. No, If I wanted everything to be properties, then I could use on I'll just say echo upper kiss. All right, I'm went to type this one from scratch So we're going toe, do some concatenation again, some opportunities on then I'm going toe can cutting it onto the result off the new function that we're going to be looking at named str Upper s de ia str toe upper Rather So I want to say str two on getting a bit of help here from visual studio cord on. Then the function is str to upper on there showing me to the right. What parameters, Anita passion which would be a strength so I can pass in variable that has a string as we've seen here. All right, so if I passed in name then the expectation is that everything will be open to someone to pass in name. I will just test that theory. Andi, I just can't Cutting it at the art tag at the end to make sure that we get a break line afterwards on when I refresh this than Trevor Williams is printed in upper case. All right, so these are some useful little functions that are there. All right, on then. In the same way that I have to upper, I have to lower. So I'm just going to duplicate this line on I'm going to see lower kiss on, then this function would be str to lower. All right, on. Since all of politics is already in lower case, I'm going to show you that you can pass in a variable already, Candice, right? The string that you wish to enter some just goingto Burpee is the variable with on a per case sentence. So this is all over. But brother, this was all upper case. All right, So the expectation is that once we pass any bit of text into the function str it's lower that it will become lower case text aren't so. Once I refresh, then we see I wrote it in as all uppercase. So I'm sure you can appreciate if I echoed it like this, then it would all come out in our caps on bypassed. All these capital letters into the function start to lower, which effectively converted everything into lower keys. All right, so, so far, some further distinction between our sections. I'm going to put in some HR tags, but then remember, you kind of put in the each are attacked by itself. Once you're inside of a pH. Peter, you actually have toe a coal this the screen. So if I want that, I simply cool. So I'm just going to call this a charter between the concatenation section on the case transformation section aren't on. Then we will be moving on to some other little features that help us toe. Repeat. So the 1st 1 that will be looking at is one that helps the story. Peter strings, I say echo, Andi, Repeat stream on going to conquer, tinny it onto a function called str on the score. Repeat, Now you may be seeing Oh, this may be a lot, Remember? You know you can't commit all the distant, and that's fine. I mean, it's years off practice that allows me to do this so I can appreciate if it is daunting. But just remember, you can always research you can always find resource is to help you find the easiest way to accomplish what you want. But this is good knowledge, regardless because then it helps you to be on more rounded PHP developer. All right, so I'm going to print repeat string on Dime Con, coordinating that static text onto the result off what off dysfunction is going to return. To me, that's a value returning function. Essentially, if you haven't done functions, that's fine. But this is going to return a value on that values what will be print. It will be contact in a tid in tow. This statement. All right, on then, I want to contact you need a B R tard. All right, so str repeat actually helps us to sit one value, whether it's a variable, whatever it is that you want to repeat on home many times you want to repeat it. So let's say I wanted to print name or my name 10 times. All right, well, let's start simply, I wanted to repeat the letter e a 10 times. So the first Parmenter in Este repeat is a or or the string that you wish to repeat. All right, So when you get into functions, starts off gamble parameters and values on the value types that need to be passed in So the 1st 1 is a string. It has to be a string cause this is a string manipulation function. We passed that in by just, you know, making reference of the value on. Then we see a comma on the number off times that we wish to have it multiplied. So, you see, I'm getting some help here from visual studio code where it's saying, Okay, the first variable needed to be string check on then Nixon needs to be an integer or a number which would determine how many times I repeat, which means that camp put another string. There are s, it will brief. It's up with 10 because I want the letter a to be printed 10 times on. Then if I refresh on everything, should look at me differently with the lines. Here we go. Repeat, string how we have a occurring 10 times. If I change that string to be repeated Once again, I could put in a variable so I could put being the variable name on there. You have my name being printed 10 times across the peach. I extend this a bit more. What if I want to? Let's go back to the letter, is understood to undo and go back to a what if I wanted E to be printed in all caps? I wrote it as a static common case. What I wanted in all caps off course. We could just do that. But I mean, let's let's face it, that's a bit too easy. So and another that needs to be difficulty. But I just trying to show you something that you could actually nest all of this inside off another function. So I could say, str toe upper on then I'm passing in all of this. So let me break that down for you. I'm seeing str toe upper, which we looked at before, which takes off string as its perm. It'll on then, as so as its parameter I'm passing in this other phone Sean call, which returns a string on their string it's returning, is the letter E 10 times. So it's returning the common letter e 10 times on that's going to come back as a string on . Then what we're doing is calling str toe Oprah on top off that string that is being returned. So in other words, and I really should have duplicated this session of serious did some just duplicating it so we can see them side by side, or at least on the same screen. So str toe s Terry Peaches printing 10 lower case is no, I'm putting those 10 lower case is inside off another function called It's their toe upper , which should capitalize everything in that. So when I refresh this screen, then I get the first song, which is all lower case isn't and I get next on which is all uppercase is all right so you can actually nest functions That's what you call nesting on combined them to get your desired results. All right, let's move on to some more fun stuff. So there is another phone shown here called Sub String that I lows us to get a portion off a string. All right, so I just stopped that so quickly and this is the this is the form off the substrate function, so it's really sub str on What it does is stick a string, variables, anything a string value. So whether you stored it in a very boy, you're typing in the value manually on it, say's from what? Starting points to what ending point Do you want me to extract? So, in other words, travel or Williams between the two words This has seven letters and this has it all right. What? This is swsub str function is seeing is that start from the fifth letter? So the fifth letter here is all on Get me up to the 10th letter. All right? No, let me retract that it is starting at this Carter, get me this many characters afterwards. That's what it's really saying. All right, so in other words, starts at the fifth character, which in this case would be 12345 So the oyster is their starting point, and it really means start for 10 characters after the fifth character aren't so five means Give me everything after the fifth Carter on then this number is as many as 10 on spaces do cone, so I don't think that the spaces exempted heart, so it would be 10 species from here. All right, so without counting that I actually just run the court and we see what happens. So we'll just go over here, refresh on. There we go. So you started at all, and that's the fifth. And then it goes on and is getting 10 characters in the string from starting from the 5th 1 So if I had just this and I said, maybe three, I want to start from Third Carter and get five characters off the words, then that whole dynamic would change. And I'm just getting the end off mining, which is war on the space, actually are. That's 1234 And the space makes five characters. Okay, so that space bear in mind that this piece is important. All right, so I just I did a bunch more, um, functions here, and we can just go through them because I think we have the general idea. Each function does something differently on do you know, it allows you to be creative and toe explore. The courts are just pushed through with all of them. So we have another one here that says Get position off string. Meaning you use str pos. That's the name of the phone shown on you. Pass in the string on. Do you see what character or Carter sequence you'd like to find the position off in the string? No note strings are just like Ari's or Ari's are just like strings, meaning what strings are just like areas, meaning the first letter is always zero. All right. So that's why you know, with our sub string, you would have started after the third Carter because it's really 0123 So it's really the third car. Go by the counting like it's on hurry. Why it would have started on the 4th 1 All right, so just the same way when we get position, remember that the first very first character in any string is always going to be zero. So if I said find a position off the w on Die refers under when I do that, you're going to see a bunch of things. But the position of the W's it because I have 01234567 The space cones all right, the space those going to seven on this would be the if because it started counting from zero. All right, so that is hold that function works on then for the other ones, you have one. That's his fine character. And we just passed in the Carter. So we have str chr on we pass in the string and then the character that we want inside of that string on it will return. You know where it is. Kind of ivy will kind of show you where it's starting from where at least the first occurance off that cartel. So it is case sensitive in this case because fine character capita are didn't work because they're no capital ours inside off that string called name. All right, all right, so adding some more functions to this We will know. Look at how we find the length off a string so the length of a string would be phoned by Str Lynn, which which will just return whole along the string is if you want to know how many characters are, well, hole on a string, it's how long a word. It's so long. Ascendance. It's so many characters are in that continuous block of text. So when I refresh this with his first look at str Lin on the length off the string off, my name is 16. So we're finding the length off the variable name on that means that if it starts counting sorry, it starts counting. 12345678 9 10 11 12 13 14 15 16 Carter's No, please note that the length is how many there are. But if we're going to comb won't asshole, the other functions would have been processing the string. Well, we start counting from 0123 So it's always going to be in minus one. Where Aeneas str ling You can always run a variable if you fit Is a meter like a for loop over a string or something like that? Always remember that it's the link that whatever valued Lynn the SDR, Lynn returns minus one. All right, now back to the other function, The next one that we want to look at is the trim function. So firstly, I echoed a sentencer without the term where the letter e. Then we have another weaken coordinating that letter a on toe string with a space, B, C, D and space again. Then eat. All right on. If we look at it, then we see that we have it without any trim. So without trim, who have a space be space either, And that's human readable. That's fine. Alright, then. The next operation that we carry out is to actually stream the spaces on both sides, so this has no spaces in it. That's just the letter A, but that I'm going to run the trim phone son over this text. So what trim does is take off any spaces that might be to the left or to the right off the string. So remember all off. This is a string it's not looking at. Each letter is just looking at where the quotation marks start on where the end, and then it's going to say, Is there any space between the first character and the open quotation mark on the last character and open quotation marks on? Then, if we put the inside of this trim function, it will see remove all the spaces that are there. So if we look at the old put off this line here 41 then we will see that it will have A and B joined because there is no longer in the space between A and B on DND joined because there is no longer in the space. But see remains the same because once again, the trim only works on the extreme left or the extreme right then variations. The truth are ill trim and our trim the l means left on the army's right. That's all there is to it. So the L trim just see is true mall spaces to the left and archer means spill. Trim all spaces to the rights, so trim those on either side or both sides on then you have functions for either side. And if we look at the old put off those, then we see that for the ultra Um, the B has lost its space, but the demon tens it sold on then, for there are trim. The B maintains its space, but that he has lost its sword. So that's really the difference between those two. But once again trim those either side, regardless on then. The final one that we look at is the replace, so you can use str replace on then you pass in your string that you're looking for the string that you want to replace it with on. Then you pass in that string or the variable with a string that it should find this in onder place with that. All right, so when I refresh a note, none of these are actually making changes to the actual variables. They're just MEK allowing you to make changes on demand boiled, maintaining the actual string. All right, so if I look at the old port for that, then we see that we had in class sit with rock where initially it was stand with rocks. So we have the original thing being printed out here nonetheless on. Then we have the modified one here because undermined, we just wanted to say, sits with rock instead of stand with rock. Well, that's it for no. With our string manipulations, there's a lot more to it. But this is enough to get started and enough to get you excited. Andi, if you have any questions, comments or feedback, feel free to drop me a line and let me know 12. Date and Time Manipulation Functions: Hey, guys, Welcome back In this video we will start looking at debt on time manipulation using PHP. Now, as we've been doing so far, the first thing we do is create a page for data and time manipulations. I just reuse this one and say the it's time my nip PHP on renamed the Linked to See It Deeds on the time my knee Puli shot next up is to create our page. So we call it state time my nip dot GHB on. Then we duration of five boiler plates. Change over title put in over each one tug, which we always start with. Just copy and paste on. Then we start with our PHP tax. Now, our first challenge today is what if we wanted to get a time stamp? How do I know what time it is right now? So really and truly the time, right know is relative to the time on the machine or the server that you are using meaning at the time on my machine right now, which is my server is wrong because it is Well, it's actually after three PM, right? No, but this server time is it's 59 all right. So when I do get time, I am going to get whatever time is on the machine. So the machine time is wrong, Then your time in your application is also going to be misrepresented, if that is not the desired results. Notwithstanding that we can just go ahead and echo and I'll echo inside off a p tag. I saw this open and towards the P tags. Same time, Andi. I'm going to echo, and I'm going to see if this works get eats. All right, so that doesn't work. And that's because this is a phone shown call and not a variable. Earlier we were talking about interpolation on. Also, I'm using single quotes and double court. So I mean, this change that coat on, Then we can go ahead and adjust. So what I'm going to do is, firstly declare a variable, and I'm going to call it a day it No. All right. And then I went to meet this verbal, have the value that is, get it all right. And open and close quotation marks. So whenever this speech is going to be run, this court, once it's executed, is going to get the exact date and time on the machine when the peas loaded. So to get it accord without any hassle, I'm just going to using interpolation. Andi put in. Did know. All right, so it's just not the injected in there, you know, just it's blue in the orange text. Alright, so now I'm going to go back toe my index speech and indiscreet candling to get to the new page, and we see that we have a slight er here. So this kerosene that we're trying to put on Ari to string on that is not a load. All right? No, let me explain this arrow as it is a very valid URL get the It is actually going to return on, Ari. So this day no is really an aria. And we looked at our ease earlier in our exploration. Are so Honore is contiguous collection off data know what we didn't look at was the ability toe actually reference the sub scripts using named while name subscript as opposed in America sub skirts. So, in our original record and I can just school. But there we looked at having an area off just numbers and then looking at each number based on the position it was in inside off the area. When we look at date and time manipulation and we look at a get date that didn't know, actually, storing each value offer dates, which would be the months or the year are the day of the week in unnamed sub stripped. So we're going to actually go through that So I can't print out this Ari just pick or the area it won't work after echo the value from the Ari that I wish to see. All right, so I'm just going to write a bit more court here on. Then I'm going toe a court, today's date and if you look at his family using the double quotation marks because I need a single court inside, so that's going back to order, saying about knowing which one you start within, which when you need to end with some using double courts because I need a single quotes inside today's date. All right, on, then, I am going to brake line on. Then in the next line, I'm going to show you our next few lines are just duplicated on. I will show you eat subscript. So the first named subscript that I'm going to use is M B. So let's see how that works. Now you notice the red line on the needed because really ensure that this there are limitations to the interpolation. I'm I'm trying to be a big to France's. I'm just showing you that there are some limitations to what you can do when you're trying to do the interpolation. When it comes to the name, the variables, because we have the presence of the quotation marks and so on, you can get some errors. So what I'm going to do is just remove these tags on. Take it out of the quotation marks. I'm just printing the variable. But then I'm going to con cutting it a break tag to make sure that the next line gets printed by itself. All right, so then when I refresh this speech on look, I'm still getting these errors because I still have that duplicated called transparent ari to string. But then this line is producing the 21 because why I am doing this video on the 21st of September. So MD is the way you get the deeds. The day The actual d off the month MD against us once the so that's the D off the month. Alright on then. Similarly, I can and I have to do the same with these because after reference, unnamed subscript so I can just modify the string here and just contact. You need a BR tug here. All right, so the named subscript for the month itself would be so I open the square brackets just like I did in the previous sorry video. I opened a square bracket. But this time, instead of using a number after use a string cause unnamed, it's a named subscript, so I'm using the string one. All right, so that's something new about Ari's. Our honoree can be referenced by position or it can just be referenced by the name. It depends on how you create the area or hope the original Ari is. So we had no control over hold. This one does it, but this is what it expects. So when I do that, I'm going to get the number nine because nine is the number associated with Sept, and we can just look down here at the clock and see nine slash 2120 19. All right, and then in the same we I'm just going to duplicate this since we have the winning formula . No, and just remove that line on then I want the year someone to write the word year. So name subscript for the year is the word year, and I refresh that are we get 2019. All our fares are gone and no, we have three characters are three values rather that can give us the beat so I can actually print the date in one land. So this PICO on DSI two days and then notice notice what's happening here with my ankle. It's giving me an error because I'm using the quotation mark your quotation mark here and there. So because I want a single court, Derek, and just wrap it all in a double quotation mark. So today's date that I'm going to contact in it All right on, then. I'm just going to echo Well, I can actually just take each off these other stopping them since already have them on a contract in its on the d. All right, then I can call Catie needs the slash someone to try and printed just like this. Nine slash 21 slash 2019. So by that, if that's what I want to do, then I really want month first, since it's the nine first. So I have the month slash Then I can Katyn eat on. Then I'm going to contact any the D value here. All right, so that's a pull off concatenation. So we couldn't printed Tote in one line just by seeing get dates and printing. Get did it. But we can get the individual sub scripts and then just concocting needed in tow, one sentence on one structure that we want. All right, so that's the sorry, that's more honest than be. And then we're going to know equal in the year. So let me just based on then changed at the year, some echoing all. And I don't need to echo each time, sir about that. So this one echo can serve this entire block. So that's why we're getting those right nights, understand? To remove all the extra echoes. All right, there we go. So echo on were echoing this one string attached to this next string attached to this next one. What I didn't do between the months Andi that while the d and the year is putting the slash , so I just make sure I have in that slash here. So I have months the dot on what I should have is the stream toe. Have the slash on then concatenation that onto my year and then and all of that with a semi colon on. Then when I refresh, I'm going to see it. Today's date is the 21st off the 9th 2019 So, based on your country, based on your four months, you can always re arrange that. So actually I'm Jamaican. So in Jamaica, we prefer to have be month era as opposed to month the year. Right. So I can just rearrange this by changing this the m d and then change in this store month on the mirror on. Then when I refresh, it looks more friendly to my cultural context. So you make your decision based on your audience? No. If I wanted the time by itself, then I could actually just echo Andi. I think I can just say time. All right. On that sea hole that works up on. There we go Well, time is going to come by in some UNIX value. So let me let me just break line here. So let me just concoct in it b r tug here, Onda. We look at the time value by itself, so that's the time value. And that's what you call like a UNIX. It's a UNIX value, so it will make very little sense if you've never really used a UNIX system, so you can see that this is not very human friendly. When it comes to the time, however, get did actually has named sub scripts that actually allow you to see the time so you can see our justice in where you would type year Mornar MB. You can see hours. You can see a minute. You can say seconds if you need to see an exact time stump once again. This is one of those things that you probably won't commit to memory and remember, everywhere you go every day of the week. But it is something to bear in mind because when you need it, you need to know exactly how you can implement it on what your options are now. In addition to those options, with the date function. You also have ah date function that can give you a formatted beat. So you just see m four months before the why four year? All right. And what a reform Until they want slashes are dashes are spaces on. Then you can actually just put in something for that time. Stump. Andi, you would be doing all of that on top off time. All right? So time is actually like a value since the beginning off computers on these, since it could be calculated so this value can actually mathematical be broken down into a B months year on time value as that? No. All right. So when I do that on die print odes on notice, I'm using a word print. So upon to know, we've been echoing. You can also say, Prince All right, so I print on seed beats and then pass in that time value on what it the day those is former. This time value of the seemingly unreadable time value into a readable format, as you desire on what it does is give me the months that be the year, Andi. Well, I'm not sure why. My time is seeing 23 when it's really it's really 21 all right, but it seeing 23 on day 18 on 49 seconds. So it's 23 80. And I guess maybe my server clock is wrong. Maybe this representation Oh, I think I need to change something in somebody. You probably won't be having that challenge, so that's fine on then. In the next line, I'm actually printing something else to do is on am printing that the off the mourns the year on a bunch of things and you can see the translation here. So I'm saying, today is that day that year off September 2019 at seeing 11 18 PM See again I just instead of seeing 23 100 or 23 hours, which is the Army time for 11 able just 11 18 PM That concludes today's lesson on date and time manipulations. Of course, it can get more interesting than this, but as you develop into a PHP developer, you find more use for these functions 13. User Defined Functions : Hey, guys, In this video, we will be looking at functions in PHP, no fooling or previous video with string and eat time manipulations. We would have seen that quite a few functions are actually available to us in PHP. But then there are times that we want to actually create our own functions because, well, we have to repeat a task on. We don't want to type that court every single time. So a function is a perfect way for us. The developers toe actually put some bit off court that we may want to do repeatedly inside of some constructs. That makes it easier to just make reference to. So as usual, we start off by creating over link toe, our new page on also over Peach. Having done that, we navigate toe, are newly created page on, Then we go ahead and include over Asian five boilerplate. Next we feel old the title Andi sit or each one talk. So I've gone ahead and done all of that. Onda opened up our PHP tarts. No, the first thing that we want to look at his defining a function, so I'm just going to make a comment here on DSO We know exactly what we're doing defining function, all right. And then a function, as I said, is a way to actually have your cold one time in some construct that allows you to make reference to it on demand. No, to get started with defining a function. What we have to do is use the keyword function, so we're f u and C t i o n. And then we give dysfunction some name. So I always recommend that you name your variables. Well, you know, usefully according to what you restoring in them. So in the same way, keep your function name kind off useful toe what it will be doing. So if I went to write a message, I'm just going to see rights message on. Then I need an open and close Breece. All right, and then I need open close curly breezes. All right, so this is a typical form off any function, you have the key word function. You have the name offset function, and then you have open and close parentheses. So the basic level that's what you need on then. Whatever it is dysfunction will be doing will be inside off these curly races. So let's say this function is supposed to print a phrase and say You are really nice person . Have a nice time. So inside off these curly braces, understand? To write my echo statement on. Then I will put in my expression. All right, so if we save this and then we load over page and take a look, we shouldn't see anything except or each one tug. And that's because even though we declared sorry, even though we declare the function on, we said it should echo the function itself is not being called. It's just defined so you can actually define this function with whatever action it should carry out. But this will never get executed unless you explicitly call it. Now. This brings a store next task which is actually calling this function on calling a function is probably the simplest part off this exercise, where literally all you do is just reference the name that was given to the function. So we saw where we wanted to turn a string into all caps and there was. This function is to str toe upper. We can always go back and look at it right, So all of these are examples of functions. We didn't define them, though, but we're just calling them. So we're passing in some value and calling the function, and then it is doing something in the background. So that's what I mean by a construct that will do something without you needing to repeat their code. Except these were pre existing and know we're looking at making our own or having user defined functions. So to call a function, we follow the same principle where we just reference a function by name, which is right message, and then we call it a few times perimeters. In this case, there are no parameters. So we just open and close empty breeze on, then a semi colon. And then what this will do is actually call the function and room that echo statements. Right now, I'm going to just modify the spectral statements and put in B R tag here. All right. And then I'm just going to show you that any time you need to actually print this or do that, you can just make reference this function whenever you want it. So if I wanted to print this five times. I can just call the function five times instead of echoing this statement five times and when I refresh. And that's why I put in a br tired so that it would all come in different lines each time. But each one of these is just a function call on. I can do anything I want to do in between. If I wanted toe have a line in between. So maybe I record and HR tag. All right, and then after that, each are tired. I wanted to write message again, and I'm just going to copy and peace the phone showing call. All right, Andi, if I go back, then you will see that I have one function. Call something else and then another function call. So there's no limits the number of times you can call this function. You know, one thing to notice is always a good idea toe. Define your function before you make reference to it. If you attempt to do it in the other way in the other order, then you might run into problems. It's always good to have your function definitions at the top of your page on, then the rest of the court don't Bill because then when the page renders and it hits this line where it's referencing it, it knows that it was already declared up top. Now let's look at defining Another function on this one has parameters. So I'm just going to creates a new such done here on what I'm going to do is define a focus on I would call it add numbers. All right, so I write my keyword function and then I'm calling it add add function. So this function is going toe to numbers. Now, the two numbers that I want to add I want to be able to get that from my program. I don't want to predetermine those, so I'm just going to put in my parentheses in the parliaments of listing a space for number one on none too. So I did mention that you have parameters. So if we look back here whenever we passed value into the function call, that was us passing in a parameter value. Okay, so in the function definition for you, see, first word you see it has function, you see first and then it has some variable called str so that is the parameter that it was defined to look for. However, it is just saying that you need to pass in something here that is off some form of string value. All right, so in this case, I'm just hinting at my users that whenever you're going to use this function called actual son, I need a number one on a number two. It has to be Also, I have to get to numbers in order to carry all the action. So then I went to go on on. I'm going to see some on we're going to do a bit off. My fear is equal Toe number one plus numb to And then at the end off that I'm going to echo on. I went to get there, be creative with my equal statement, and I went to see the some off number one on And no, um to is colon. And then I went to print the verbal some. So I'm using my interpolation here on day. I'm getting some number here. Some number they're doing some month where I'm adding them and storing them in another variable called some on. Then I'm going to say echo the some off that first value and that's gone. Value is on, then have that final value on then I'm just going to print a B r tired after that. So in case I call the function multiple times with multiple values it will print in different lines are so no, no, that we've defined or function, and it's called Add Function. I'm actually going to go down and I'm going to call at function. So what if I wanted to add two numbers, maybe 10 and 20 and then let's see what happens. So I go back to my page refresh, and there we go. The sentence is printing printed, seeing the some off 10 and 20 is 30. So the interpellation is working, the some off whatever value was passed in as the first variable hard first parameter, which is 10. That's what gets stored in this variable called number one. And then I passed in 20 and that's what gets stored in, numb to on just the same. We if I had a variable and I called it just numb, and I assigned 500 to it. Then I can call that function again and the Nike NC I want to add 10 toe whatever value is inside the variable. No. So it doesn't have to be a static value. This is required a static value. He can be a variable all right, as long as it is a number, because what I'm doing has to do with numbers. So if I pass ministering, then it is probable that it would break the function. So it's experimented that What if I passed in a string instead? Off number 10? Let's see how that would work. Boats that's passing two strings. Some went to pass in 50 Antin, and I'm using the two different quotation march. So let's see. Whole flexible PSP is our is not on. If we look at what's happening, it's printing out. Some off 10 and 500 is 5 10 on the evening flew past in a string. It's still kind of doing the math. Are, as we discussed earlier. PHP is not very strongly type, so it's not went toe. Hold it ransom. For if you use a quotation marks, sometimes with a number, it's still going to kind of process it and contextually say, Oh well, evenly passing a string. The string is a number on you are adding, so I can still do this higher. So that is whole. A user defined function with parameters is defined on, by extension, this issue which is called No. On the flip side, you can actually pass a perimeter into the function. Well, we just did that. So this is what you call passing by Value are so we have some value here, and even if it's another variable, what we're passing it in by value on there is nothing I can do in the function to actually change the original value off known. So even if I said here, that's gnome is no equal toe, whatever Valium is. Plus one. Which means if nomis 500 at the end of this statement, numb should be 501. All right on. So even if I'm passing it in by value on, I'm trying to do that. Well, that really wouldn't work. How sorry. Seeing them too. Right? Sorry about that. So because I'm passing the value off gnome in tow, the number two barometer. Then I would have to try and manipulate gnome through here. So what if it was a case where I wanted to actually change the value off numb using the function. Well, what we're doing as passed by value is not going to do that because the value off gnome will not change. So to prove that if I go ahead and call number underneath this, then I'm expecting to see 500 get printed again because the value off the gnome would not have changed. If I refresh that I'm still seeing 500 it's not. It's not space because I didn't put in the actor. No, if I wanted to be able to modify the value off a function sorry off a variable that is not defined inside off a function, then I have to do what you call it. Passed by reference. I'm just going to define another function. And once again, there is no limit to the number off functions that you can have. And let me just say this one is going to because change numb. All right, on, it's going to take a parameter cause no, right, because what I intend to do is pass the past this value into this function. Now the tool can have the same name But as you see appear, you can have different names because this is no more number two. So once the value hits one of these, it is no identified by the name Numb to put. If you use the same name, it's off Reno. Real consequence. So this is actually going to just say echo? Well, it's really just going to see no is equal toe No, plus 10. All right, so my objective is that after I call this function and I'm going to pass this variable into that function, this variables value should actually change, not change here, but then not change. Owt said so. Initially, it changed inside off the function, but the original value remained. What I want to do is allow the function toe actually change the value off it from outside of the function. Are so the objective. Is that Okay? I'm going to her Move this and then I'm going to call this function some just in to see a change gnome. And I'm passing in my terrible numb. All right. Sorry on then. Under needed someone to echo. No, and I just can't catch in it. This with that beer inside. So I hope you see that there are many ways to do this BR tag on the string and the printing and saw him because he could do it all in 19 with interpretation concocted. Nate it on. This is really a number being concatenation onto a string, so they're quite a few options available to you. All right. So, back to our objective. I am trying so Mont make change gnome change the value from being 500 aren't know what I need is, uh, let's see what this those first. So what's going to happen is that change them is going to get called and then it's going to pass in the value that is stored in Nam, which is 500 then changed their mistress meant to say 500. Well, this variable is no equal to whatever it's folly was plus 10 on a short illiterate this and I'll just read it underneath is actually numb. Loss equals on in the value, so that's a no more so seemed we direct this fire. So I'm seeing 500 plus 10 on whatever valued this comes upto No, you store that in that terrible, but what we're going to see is that even though we're doing this modification by the time it hits outside off the function and echoes the value off gnome, it's still going to be 500 on. Let's see exactly what I mean. So you see, it's still printing only 500. Know what our objective is to make it print the end result off what is in the functional Onda once again, the only way to get it toe modify that is the passage by reference. So what we need to do is add what we call an 1% which is on sign, which I believe if you're using a Western, he would at least it's shift and seven. That's an 1% you pasa in before the variable, and what that does is passed a reference storage area off the variable. So then it gives the function ability to modify the original value off that variable, so passing by values just like copying and pasting. Think of it like a bunker cult. So when you pass by value, that's like me telling you that I have $10,000 in the bank. A coach that doesn't mean anything to you because you can't touch my bunker, Coach. You can't change the value off my bank account just by me telling you it's $10,000. So that's what we call a pass by reference, however, when you pass by. Sorry, that's what you call pass. By value, however, will be passport reference. That's like me giving you my debit card on the pain on my bank account number on by logging for my bank account online. And then you can go and you can withdraw money and actually effect a change on my bunker. Coach. So that is what we call pass by reference where we actually include this, um, percent. So it says, give them give the function all the details off the variable on pretty much that variable can be modified inside off this function. So even when the function execution is done, whatever modifications occurred still obtain outside off this function. Well, this past by reference can be doing to as many variables as you need. So even here we could have just included the 1%. And if you wanted to change the values off number one and number two, we could have done that they're all right. The final thing that we're going to look at the with functions would be how to set up a value returning function. On that example off a volley, returning for son would be one like, Well, any off the string money, police on functions. So what is actually happening? Let's take repeat string, for example, is that str repeat is getting parameter number one a perimeter number two. And if we over over it, you would see that it is input on multiplier. Fire on it is getting those two and then it is actually returning the end results. Which is why we could just concoct in a tit onto the strength. So what I'm going to do is create a function and I want to call it return. That's a product. All right, so we're going to do some month again. So we're going to take variables numb one. Andi numb to and then you notice I'm still using number one and number two. But we already have them here, and I think would have established that you can't declare two variables with same name. So what happens is that variable is only alive inside off the curly braces of a function, and we call that a function scope. So inside off the curly braces, then this variable exists. Once that function, Collison and the the program jumps out of those curly braces that function no longer exists . So that's why I can. I'm able toe use the same names, multiple places inside off my function parameters. Alright, someone open my curly braces are start defining the scope and scope of actions for dysfunction on. I'm going to say prod is equal to num one multiplied by number two. All right, so you don't use the X in PHP four months to use your Esther's Andi. Then I'm going to have another keyword. That's his return, and I'm returning the product. I'm returning. Whatever value comes into this, I'm returning it. So when I call this function, I have a few options available to me. I can echo on Geico. Whatever values returned here, I can start in a variable, so let's try that variable option someone to see return value is equal toe. And then I went to do my focus on call to return product. Andi, I'm going to spurs in, Let's say, 10 and 200. So once again, the expectation is that I have a variable called return value on its value is going to be set to whatever they value is that is being returned by this function car and this function call getting the parameters 10 and 200 spoke. Thomas Agricola is going to go ahead and get the product off 10 and 200 or 10 times 200. And then he's been to return that. And then whatever it returns, get stored inside off this variable. Which means if I wanted to echo the value off this variable, I can just borrow this line off cord and then I'm going to echo return value here on the news. The function call. So once again have ah for have, ah variable. And it's going to set its value toe. Whatever is returned from this function, call the formation colleagues. To turn product is getting two parameters. Two values as perimeters on it is defined by us the user toe. Except these parameters get the product and in return, that value on Then I can no echo that value. So if I refresh my page, then I will see him getting back that 2000 end results. Now there's a lots more to come with. Looking at functions in PHP. This is the tip of aspirin, but it gets far more fun than this. I hope you stick around, and if you have any questions, feel free to reach out. 14. PHP Include and Require: Hey, guys, welcome back in this video we will start looking at our include and require statements in PHP now just to give you a bit off but grown US toe. Why include on door require are useful. We would have been so far, creating a few pages. Each time we go ahead and create a new page, we would include the same code every time. All right, so let's start off with our index speech. We have the Asian of five boilerplate, and yes, we have a menu. All right, on the next page, which, let's say it's Ari, we have the same additional five boilerplate. The only difference is that it doesn't have a menu. Now in website design, it is always best practice that every page can be gotten toe from any peach, meaning the menu should not just be on our end experience. But it should also be present on every oper pH on. You can just imagine how Tito cities that every time we create a page, we have to remember to include the menu. It was already kind of tedious doing the issue of five boilerplate each time, and the fact is down the road. As our website grows, maybe we have a change to make in the links in the menu than if we had 50 pages would have to go through and make those changes toe 50 pages individually. Now our include or require directives. They basically do the same thing, just just a little difference in the way they operate. But they actually allow us toe. Include snippets off court or snippets off. You know ph. B R. Html wherever we want, so it will be similar to how we don't have function. Just know where with a function. You have a block off court that you don't want to write over and over and oversee. Just put it inside of a function and call it when you want well over include or requires statements I low us to take. It's off court life, for instance, the heading part off on a channel page put it in a file and then just call it on demand. So in this tutorial will start really rearranging our restructuring or pages toe be a bit more, you know, flexible. So instead of being static like this, where we have to make sure that this court is the same everywhere. We're going to kind of have it one place and just included in every other page as we go along. We'll also look at having a proper folder structure so that we know what files are for what on where to find everything. Once we start putting more, resource is into our websites that the first order of business is to create a folder on I'm going to call this folder includes. And that is just there's no particular reason for it. Some people call it snippets. Somebody calling includes It's up to you. You can call it what you want, but essentially, this folder is going to play host toe every court snippet that I intended toe include on every page. So the first snippet that I want is the entire snip it off the top part off the HTML pages up to the many because I want all of this block off all that I have highlighted here to be on every page. Once again, we all have all of the boilerplate code, but we don't have the many, so the menu is made shift right now. Don't look at the aesthetics I just wanted to get the concept off having a more template ID website. So the first thing I'm going to do is create a file inside the folders understand ticket the folder. You can always still afford a different from the files because it has that little carrot, but it's pointing to the right when it's, you know, collapsed and when you click on it and it expands it, points don't are. So I'm just going to click on it, and I know it's selected because of the blue, and then I'm going to create a new file inside that folder on I'm going to call this one hitter dot PHP and the reason I'm calling it header is that the header file is going to have all of what should be at the top off the page for me on That's me. That's how I am designing so you don't have to follow that. But I'm trying to keep the names as useful as possible so that anybody who comes along with seat and just, you know, deduce what it's for. All right, so what I'm going to do is actually take all off this score all off this bit off court on caught it from this file. Look at that. No, we remember that every HTML page should have that structure. That's why they give us a boilerplate. So we all have the skeleton. But what I'm about to do is butcher the skeleton inside my cord because I want toe be able to include it on demand fire. So I'm going to take out all off the top parts, understands on do and do it once again. So that's from the dock type street up to the closing you. Well, so that's all off the head on the starting tags for the bi Onda. Everything else that should be on the page. Well, at least everything else for the menu. I'm taking all off that I'm going to cut and then I'm going to go to header on. I'm going to paste. It's and no if I if I go back to my AIDS. And so he has to love that functions file open. If I go back to my index speech, I'll see Okay, there is no menu, and it's sort off rendering properly. But then, if I look at the cord, I just pressed F 12. So I'm using Internet Explorer and after have brought up the inspect element console and you don't have to do this part. I'm just showing you that well, Internet Explorer's trying to compensate for the fact that I did not properly for my pH. So you would remember that the head type farm or quoting that on the body Terry is there. But if on a normal be in a lesser browser, this would not have happened, it would just be probably Eros. All right, so the fact is erupted. Tote off the head on dso Internet experts trying to make do with the new core which does not have all of this stuff in the head. So they see the head drug actually had stuff in there on the body tag started and didn't finish. But that's all in header. So what I'm going to do now is use a keyword that's his include on then after include of quotation marks and I can use single contusion marks on. Then I am going to make reference to the file that I wish to include so well. Firstly, this has to be inside of PHP tags, so PHP bad all right and then we see include which is our key word. There we go. There's a color quoting we're looking for and then the file. So the file that I want to include at the top off my index page is my header file on the header file is inside off their includes folder. So that means I need to see includes because I need to make reference the path slash hitter , start PHP. So all those 13 lines off court just that reduced toe one. So we're so we just have that 20 lines off court one place here on Do we just meet the change one place on then on? Any other patriot can just use this line to make reference to it. Let's test the theory. So if I go back and reload my index speech there I am, I'm restored toe what I had before. I have my menu. Alright on defy inspect element again on having person after the first time. It no, I lows me to inspect element or view source here, but I'm seeing that the court looks like what it used to look like. So the bro's there is no longer compensating for me. It's just giving me back. All right, so that is essentially ho. The include works. Andi, just to build on this, I can actually go ahead and use that block off board anywhere else. So I'm going to start removing all off the top part off every file. Right? So we went up the body. This will serve you hitter. So we have up to the body tug, and then we have the menu. So I want the menu on every page without talking to putting all those 20 times over and over and over again. So I'm just going to start removing up to the body tag and just replacing its with the header. Alright, Andi, I can do that with each page and I'll just do it. Andi again, you We can do that together. It's quite simple. Just click each one and then save as we go along off. Worse. So this is functions. If statement and you notice that I'm kind of changing the title so the title is actually going to be changing each time, right? Because it's was set toe one value inside off header. But we'll get back to that you'll revisit that. So we're almost done. And no, if I refresh my pages on dive, go to anyone off them. I see that I have that menu there. So that is one nice, simple, surefire way to make sure that your menu or this this link was putting incorrectly. We can fix that, but this is one surefire way to no, that we can include or have or menu static and Andi consistent across all pages. And if it is that we need to make a change life, for instance, string money police on the link here is wrong. Oh, I rode sting money, not string money. So instead of having to go and change it in all of these files, I came to school. One, please to the header orbit the link. See the change on then If I go back to any other page and refresh, then string manipulation, no works. And if I'm on your statement, it's works on every page. All right, so that is how you would go a boat trying toe. Keep your pages consistent without having to copy and peace, and then worry about open 56 different places in the future Now we can go about doing the same thing with the footer off the page. If I go back to my index speech, I can show you that I put in a bit off extra core Don't hear toe, actually echo copyright copy in 1999 2 on the date today. So that's a nice, quick way to get the year. All right on. Well, I got to step it from those three schools, so I'll just say ph b masterclass. Now, As it stands, this court is only set to appear on only the index speech. So let me just prove that. So if I go back home and it's always good to have a link that leads home, as you see, I don't have one. So that block off court or that block of text is only available on index page, it's not on the loo. Page is not on any other peach. Someone to do two things right now, one on one to include a link home, someone to go to my header on. Then I'm going to include a link to Index and remember, once you meet the change here in this file that will be included. It will be included on every other page. Right. So this would be home. All right. So we looked at how we include. No, I want to look at how we required our fire is pretty much the same thing. So we just require the footer. So I'm going to go back to includes, and I'm going to make a new file and I want to call this one footer dot PHP. And then inside footer on went to take the rest off the body talk. So I'm going to start from here with this speech. Mitag anti the rest of the body tag on the HTML. So remember that your body targeting issue mel type is the most close, open and close properly. So we're already opening them inside off our hitter dot PHP. So here's where body opens, and here's where html opens. So I'm just going to take the closing portions as well as this footer, footer, notation, And I'm going to take that and then I'm going to put it inside off footer that PHP. No, What I need to do is include footed up PH. B on this page and you see how much less cold we have on this, Peter. I know. It's just purely PHP. All right, so I'm going toe. Just see, open up another PSP tug. I can have as many times as I want, but I really don't need that many. I can actually just use ones are gonna do everything all right, but let's just keep it simple for no. And then I'm going to use required this time. So we have require and you know it is also have require once so require actually creates a dependency on the file. So let me say that the different way when you include, if the file is not phoned. So let's say I messed up the reference to the file and it can't find the file or I'm trying to include a fair. That's probably just not there. Then it will probably shoot a little warning. But the page will load regardless when you require. If you cannot find the file, the rest of the page crashes are nothing afterwards gets rendered. All right. So I went to see includes which is by folder name and then slash and the filing, which is footer not be HP and then I can do that across all the pages. So every other page and I still love them. Open, Understand, to replace the closing tags with the requirement for footer. And I just do that quickly. And no, that is done. We can actually just go back. Onda observe to see So the new menus they're on at the end off each page, we have the copy, right? So that's on the R ace page. If I look on the if statement speech, it's there. If I look on the follow Shaun speeches there and it's everywhere, so that's a nice, quick and clean way toe. Include or make sure a bit off court or a bit of text or something that should always be there is on every page without having toe type it back toe. Never manual. We know in doing this this this week are refractory off the court. We hit one little challenge. Each page was this being It's own, um, its own title upon to know. So every page is said to just static Alicia ph. B. Primer dash index on. That's because we would have included the header on sit. That's part of it. to be very, very, very static. So what I'm going to do is include a PHP ties here. We're going to try and make this dynamic. And inside here, I'm going to echo variable that I'm going to call title. All right, so work with me. We have our title tag, which we know we just put in the text pH b primer dash the page name. Now, at this point, we have the header appearing once, meaning this court is defined once it's only being referenced everywhere else. So there is no longer an opportunity for us to just spin up a page and say, Oh, the title is PHP Primer Dash, whatever the pH is no, we have We only have it one place. So either define one text or we try and make it. The dynamic on this is so we're making a dynamic by inserting a PHP tag on. We're going to echo whatever value is set to title. All right, now you're probably wondering, what is this variable title? When did we declare a verbal title? We haven't yet. All right. So if I reload the page, then Okay, you're seeing that it's only printing back something, and it's going to say undefined variable something, something, something. So if you're if you're following along, then you should be able to see that there are more clear than maybe it's appearing on my screen. So we need to change that error on Let it stop companionable toe. Undefined verbal. So what we would do is on each page because we know what the pages are both above our includes. We can just include or rather meet mention off variable called Title. So in the same PHP block that I'm including, I don't understand toe reflected this agency where it starts and stops. I am going to declare some variable called title on the reason this declaration has to come before the includes is that the variable has to exist before header gets included because it's looking for a title by the time it hits this line. So if I declared before and give it a value and I call this speech index on, then I refreshed my index speech. So I go back to Index. All right, on there. I see Index PHP primer dash index on guy used a common I can just weeks that use a capital I. And then when I refresh, I see it, updates it. So then we can start doing that across all the pages because remember up. Want to know when we declare a new page or create a new beach? But we would have done is make sure that our title reflects the new page. So once again, you can't put it there because it needs. It's a PHP forever. So it needs to be in the PSB block so I can just use the speech B block that has the include Andi. I'd like to have my Korean dented, so I spent a lot of time in denting my cord. But I just do this one and then I'll do the rest off screen and allow you to do it for yourself to get the practice. So I'm just declaring that this title off this pages Ari Onda that is once again being included, declared sorry above the include line. So when I go to my r a page, it should say Petri primer dash Ari, because my header is once again just for enforcement printing PHP primer dash that will never change unless I common changes here. But then I have a variable that is being echoed toe the rest off that bit of string inside off that tag. So go ahead and update all the other pages with the cart title. All right, so I trust that you went ahead and updated it on all the pages on. By the time you're done with that exercise, every page should be seeing the title with PCI Cramer, Dash, whatever it is on, that should be dynamic according to the page that you're on. All right, So when you see these big websites like Amazon and eBay doing this stuff, that's all. There really been little sitting available on printing that variable where it matters. So by extension, if we were able to be clear that on remember that whatever we sit in the title is what we sit in the each one time. Then I can simply take the same title that was declared up here for the purpose of the includes on Actually echo this very title here So I can be clear. Atari inside off my Asian all times. See that? So you know, we could echo html tags from inside Ph. B. Well, inside off the issue. A target can just put in a PHP tug on, then echo here, variable. All right. And then if I go on my IRA speed even after I just butchered the court like this, I should see the each one tug seeing our is. So when I goto areas, there we go. No, I noticed that my lynxes, Ari and printouts and I'm only seeing Ari's hold y change that Then I would need to see hurries and print oats one time. Just change it one time, entitle on. Then it will upbeat inside off the actual title, Italian hitter Andi will up deed in the each one type once it gets rendered. Let's test that theory so I can just refresh the speech. And there we see a raise Onda print odes on Berries on the principles. So this is a nice, quick way to get your court open, running and dynamic. Reduce the redundancy and the potential arrows and a maintenance nightmare that's going to come with having multiple coins where you're repeating your court. So just to review what we did firstly, we looked at having a full of structure, so we have all of our pages that we know we need to navigate to. But then we had some scripts that we needed to include on We call those. Well, we put those in a folder called Includes You could Call this folder Anything you Want. You could call it scripts authorities, but just make sure that the name is clear enough that somebody can see the folder. Indeed, use what is in there, and also the file names should be rather clear. We also looked at using the include statement on the require statements on We deduced that the include is fire less destructive to the rendering off a page, meaning If you can't find the file, it will still try to render the page as best as possible. But just shooting are warning that file doesn't exist, whereas the require will actually break your called Break Your page stopped the processing off your application because it cannot find the file. We also looked at how using variables can make our life easier on how we can include them at different points are owned or website where we know that they will come in handy. If you have any questions or comments for you, free to reach out to me and I'll be sure to get back to you 15. Website Layout - With Bootstrap 4 : Hey, guys, welcome to this new video. We will be looking at using bootstrap framework in our PHP application. Now, bootstrap is an open source CSS framework That actually helps us to get our application beautified with very minimal effort. Essentially, a CSS framework is basically somebody's brainchild when they realize that people are repeating certain CSS cold patterns over and over. Like, for instance, everybody wants buttons off a certain color when they're using their websites, you know, red for the injure, yellow for warning, etcetera. So a CSS framework is when somebody sits down and creates these CSS styles to give you these, you know, specific aesthetic compliments for your design on. Then they publish the court. So bootstrap is no different from this. A group of developers got together. They made bootstrap on. They are just trying to help you get the media things out of the way, like red buttons. Blue buttons are certain things that every website has. Nobody's now. In order to get started with bootstrap, you have two options. Option A. You can actually don't load the boot shop framework, which would come with a bunch of CSS fires and Js files that you'll need to include in the project that you're already building. The option B would be using the CD end, So here they give you actually, um, code snippets as to what you can just included in your website in your Web cord on Do you get your boot strap in the CD and is short for content delivery network, which really means that they're hosting the court file somewhere else on. You don't have to actually don't load it and included, so you can actually just reference. It's remotely toe where it is being hosted. So in this video we will be looking at incorporating it through the cdn links. Now, if you scroll down first that you get to the website by going to get bootstrap dot com or if you Google bootstrap, I'm pretty sure that they will be in the 1st 3 search results where you'll see that is actually the CSS framework and not anything else. On. Then, on the front page gets bootstrap dot com, which would be an index piers for the website. You will see the links. No, my browser, which is edge. It's kind off obscuring the court from Miss also opened it in Crume on. Did you see that? You can really just copy this code and included in your web application. So my first step is to include the CSS file. So if you close fleeting, get CSS, you have the link tug. Then you have this attributes called rail, which has a value of stash eat. Then you have another attribute, a trip which has a link to somewhere. So I'm just going toe copy this link Onda, open a new tab on bro's that link and you realize that this is really just one big CSS file . All right, so without trying to understand what's in that CSS file, I'm just going to copy this line here. So I just double clicked it to get to copy all of it and I went to control Sea on then in my website, I'm going to go into my header Onda, remember that you include CSS files in your header. So if you didn't know that before no, you know No. You always include your CSS files in your header. Someone to include that under this last minute attack above the title on I just faced on. Did you see comes with a bunch of things are the attributes you don't have to worry about those things. Essential thing is that you're putting this tug or that bit off court from the side in the right. Please. All right, on. We can see if that on then. In addition to that, we also have to include a few javascript files. So they tell us that worries in Js hopper dot Js and Jake worries understand to copy all of the's. All right, Andi, the the best place to place these wouldn't you can place him in the head. That's fine. So you could go back to your court and actually put them underneath the link to the CSS. Andi in another school of thought, they would tell you that you should put it right at the end off your web beat someone to go with the foot or file. And I'm going to please them right above the body tug right on golf course, Someone to end it. My code because I like when everything looks uniform. So I have three skirt files being included on the order matters. So if you if you're going to copy and paste mission copy and visiting in the exact order that it appears on the websites. All right, so whatever order it is that they suggested to you here, please ensure that human teen it's all right. So know that all of that is done have included the CSS file and have included the skirt files. I went to Bro's to my website, which we adhere open. So if you didn't have it open, you can feel free to open its local horse here. Folder name slash index dot PHP should bring it to the Web page. Onda I have It's open already. So I'm just going to refresh on when I do that you notice on instant improvement in the aesthetics off my site. The fund is different the way the links appears different. Everything about my size is different than that's what bootstrap being springs to the table so you don't have to sit down and write hours off CSS school together at fund to get it right. This together and colors. Bootstrap already is designed by people who know what what developers like so typical websites to look a certain way, at least in the modern day. So they pretty much just beat all of that into the CSS file. So by default, it will cause certain enhancements to your website. So let me put that in tow. Big more context. I'm going to go back into my head or file on going toe. Remove the reference to the CSS to the bootstrap CSS file. All right. And if I refresh my website, I'm right back to square one. So my my default fun. Just I think this is times New Roman Onda Fund that this links are the most attractive. But then once I included Sorry, once I include it in the cord, Andi, I refresh. Then it's an instant facelift. Then if I go to any page because I included it in my head or file, all pages kind of have that uniformity about them. So that's another important thing about what designed your pages should be somewhat uniform in, you know, the fund and the colors. I used throat. No. Bootstrap has a beat off documentation that is available to everyone actually love their documentation. To be honest, it's very clear they give some good examples and guides on. If you click on documentation here, you will bring it to the quick start and they were actually guide us to where to put what? So they say copy and paste the style sheet link cord and they actually give the copy. It's really, really, really cool. Andi, In the GS section, they tell you please the following inscription at the end of your peaches, right before the body tug. So I was right earlier when I did that. All right, on then you can scroll through and see how hold that temperature looks. So the link, its in the head on the script files are right above the body talk. Now let's start looking at some of the goodies that Bootstrap has outside of just by default, enhancing over front and colors. One thing with this Web design trend is that the pages that don't go into end All right, so right now on our pages, we have all the content hugging the left margin off for what he drives on. Every piece Looks like that. And that's not typically whole websites look, So we want to kind off bring that uniforms. So if I open a new tab here in edge on, then I just take a look at this first speech. It kind of gives me an indication as the whole webpages look, you notice that there's a margin between the right side off, the content on the right, more sparked off the page and the same obtains for the left. So that has to do with the layout off or peed. So I'm just going to on the bootstrap Documentation Guide, goto the layout section on In the layout section, they talk about something called a container, someone to incorporate this div on container into my corner Live is an HTML concert that just to me means divider or section. There's a talk called section, but I leave is really a section so you can actually create like, logical boxes around your content on style. Those boxes on everything inside off those boxes will inherit. So in other words, that give is a section on. Then Bootstrap gives us a class called container, which will kind off style. This section of particulate away and that's styling that we're looking for is that it won't stretch in the end, but it will kind of create that little margin between the left under left margin on the right side of a content on the right margin. So in my head or file, what I will do is I will open this live. All right? I'm going to open the living the header file because remember that we're wrapping the header and a footer. So after open in the header file on, I will close in the footer file and I'll close right above my actual footer text. So remember, I'm echoing this. Well, I'm going to close after this. Actually. Sorry. Someone to close after I'm echoing the copper at information. So the DeVos opened in the header on I'm closing it in the footer. So essentially I'm rapping. All that appears in between the include header and the include footer or the require depending on which one to use. I'm rapping all of that inside off this Div fire. So the Devi's opened here on the devious closed here. All right. And if you want to look back, I have the menu And then I opened the deal on Then I closed as I'm not a fact. I'm going to put the menu and everything inside the steps. I want everything on my page inside this This I'm going to move this day of opening up the underneath body. All right, on dso body begins, and then the div begins on. Then all content falls inside off that give including the menu as we know it's up to No, the page content on. Then it is closed inside of the footer after we have included over copyright information. All right, the next thing that boost job guys us to do is still put in the attribute class container. And the great thing is that you can just copy it will have to write it old on. I went to go to header on inside off this, Steve, I'm with the paste class equals container and then let us just observe the instruction. So when I refresh this speech, you see that there's an instant jump from the left margin into a more centralized Andi? Well, more. I don't know how to put this, but a more acceptable form off whole. Our web page would look and all of that was done by just including a reference to a pre defined class courtesy off our bootstrap CSS file. Now, in addition to contain as they also have a grid system, and you can play around with this. I won't be used in this, but if you need to split your page into three sections, they give you the court. Slip it for that, Andi. I mean, it's up to you and your individuality in your creativity, toe, actually, get your page divided and sectional eyes the way you were required to be. All right. So the next big ticket item would be to transform our current navigation and the steak up. Look back, this navigation construct in tow, a more user friendly navigation concert. And if you go down to the component section off the documentation, you see that they have a section for knaves Onda six and for enough bars. Andi, they give you examples off what each one will look like on the actual core that needs to go into it. So I'm going to stick with the NAVs, right? And the reason I'm sticking with announces that they have user are on order loops on order lists. Sorry that are being used with specific classes. Toe have those menu items. So if I look back up my coat that I would realize that I also used on on order list on list items on anchor tags for my never year shot. So all I really have to do is just make sure that I have the appropriate classes and the first thing I'm going to do is use The class equals now, So I'm just going to copy that over to my own ordered list on a piece that veer. The next thing I want to do is make sure that I follow this procedure not necessarily in the order or the indentation off the tugs, but really and truly in order off the classes and the tags that are used for accomplishing this end result heart. So I'm going toe add the class love items, each off my list items. So I just copy this from the documentation and go to each list item on include it on, then, once you've accomplished that, I'll go back, and the next thing I need to include is a class knave Ling. No, you notice that you have a well class equals love dash link on active and then the others don't have active and then this one is disabled, so they're really just giving you examples. If it is that you want to make one standard as active one, you can always include this. In that class list are taken out multiple classes inside of that section. Each space depicts a new class, so you have enough National Inc as one class and active is another class similar. Down here we have nothing Dash link, Andi Space and in disabled. So they're two different classes, and then they have a bunch of other attributes and you can see the disabled one period displayed here. What makes that one unique? But the point is, all of them have this in common, which is love dash link. It's understand to go back over to my cord. Andi. I'm going to include now dash link with each or class equals, not dashing with each uncle talk. All right, so having done that on added all off the new class references, I'm going to go ahead and refresh my page on. When I do that, I'll see that my ordered or the on order list off link snow looks a bit more, you know, refined. It's still not enough bar, so there's enough bar construct. But because I have so many links, I leave it like this as this is good enough for our context. If you look through the rest of the documentation, you see that you have other options. You have available styles where you can adjust where you wanted to be, what they want to be in the center or to the right or to the left. He can have it vertically. You can also have it looking like tubs or looking like pills aren't sailing scandal. Clark tubs on the links can look like pills, so if it is, I want a little hover effect. Then what you do is just include knave dash bills to your U L. So I have no love and then I'll just say species now have dash bills on. Then let's see what kind of change that means to our site on DNO that did not do anything, actually. So maybe that's one of those books that we need to report to developers that the knave dash pills did not give us what we expected. But outside off that disappointment, Another good thing about bootstrap is the fact that it makes our pages responsive pretty much out of the box. Responsive means that it re sizes are skills according to the screen side. So if I minimize this on, let's say this will be the maybe this size off a tablet. You notice that a little, very little is lost from the positioning off the content. And then if I further skillets of maybe the size up our cell phone, then this would actually be something like what the cell phone would look like. No, the nut bar control actually has a cell phone already. Menu that is there with the pills. I top the pills and many comes Don't just like it would on a cell phone. It's actually all built in tow bootstraps so you can explore. If it is that you don't like my use off the none of the knaves component, then you can always try and implement the nab our later on. In the course, we'll actually get around to doing that. So if you want to skip it, that's fine. If you don't, then we you know you can. The sticker on that. We just push through these concepts, so essentially bootstrap is very, very, very, very capable CSS framework. It gives you a bunch of options. Yes, there a few bugs that would just experience with enough dash pills. But essentially, if you go through all of the utilities on extend on all of the components, you see quite a few things you can get car ourselves. If you need a button, maybe have a button in your peach Onda. We can just go through a button example where these are all of the available button classes out of the box on. You can easily get your born to look this way just by including a class someone to include a button on my index speech real quickly. Um, so I'm going to go to my index on then I will underneath that time. So in between that last speech retired Onda. While I'm on this page, I'm going to indicate that you really don't need to open and close open and close styles like that. If you know what is that? Court will run on select. For instance, we have a pH B block here on a PHP blocked here, part of refractor in your court. You could just merge these two because the fact is the PHP block opens here on it closes here on day. If you want to extend it, you could actually just merge these two because the PS three block well, Ben's here. Andi, it closes here. All right, So, like, for this one in between, we have a bit of HTML. So, you know, you could leave this one open here and then just have one big piece B block, but then be mindful off mixing it with the Schemmel. Because if you needed HTML in between here, you either have the ECU it like this or close the PHP tug. Right? Your HTML. So, like, for instance, someone to rights bulletin here on this is a But I'm just going to say Click me. All right, I'm going to close this button in additional five button is actually attack. But then because I have html interrupting the PHP tugs, I have to make sure that this tug knows it's supposed to be PHP someone to just re open a peach, Peter just for that section off the pitch. So if I refresh my index speech, I'm supposed to get a button that says quick me. All right, you look at this Bonnet's a basic plane, you know, not very attractive button, but then I wanted to look like one of these buttons. I just go back up here on Let's say I wanted it to be a dark button. All right, so in the court example, they actually show me what court I need for a dark button on. What I need is what they give me the type on. They give me the class. I just copied the really fun part. So there's no problem with copying the entire thing here on, then just rewarding it. That's fine already created my buttons, so I really just need the essential things that are missing, which would be the type attribute on this value on the class attributes and its value. So I'll just copy that on dime went to Goto button on a piece that on. Then, when I refresh my page, my index speech, I know have a dark button. All right, so that's oppo of bootstrap. Once again, you just referenced our class. In this case, where to do was referenced Bt and on and the other class Bt and dash dark, and you see that it's it's a common you know, it's a common butter, and all of them require beating. But then, based on the type of botany near, if it's a blue button, it's beating primary fights. He was agreeable in its secondary, green and success. All right, so you can use these styles to give visual cues to your users. Sometimes uses Laurie the text of the button, but I go by the color, all right, and that will have helped them to have an excellent user experience on your site. No, I won't gets to in depth in bootstrap, right? No, there's a lot of things that we can explore, but then the context for us to use them is not really there in this side that we have been building. So I'm going to end this video here on day. I encourage you to spend some time, look at the documentation, getting familiar with them. I'm not saying you should memorize all of the classes and all of what you can do, but it would be good if you have, like a quick recall off what is available, even if you have to come and reference the documentation to see how you implement it. All right, so once again, feel free to drop me a line or a bit of communication if you need some clarification. 16. Add Project to Github: Hey guys, In this video, we will explore the steps towards getting our websites, which is speech. Be primer up on to get hope. In a previous video, you would have been guided towards creating a ghetto bar. Count on acquiring Get Tobe desktop on. If it is that you haven't done so, then you can always in your browser go to get hope that com, which will underneath this, I note because on Sandon youtube dot com, which will ask you if you want to signed in or sign up. Of course, if you've already created a con chicken sign in if you so desire on def you need to create opponent. You can always just use their user name email on a password to get that process started. You can also go to desk top doctor top dot com to download the latest version off their native application that runs across all platforms. Once you have that don't loaded, he can just go ahead and open that so we'll search for get up on our application server on wait for it to load on, then the first thing that we want to do is create a repository in our sight folders are side ful. There is PHP on the score primer, so the first thing I'm going to do is go to file Goto, add low color repository, choose and then find the destinies of which would be PHP primer. Select that folder on then, because one does not appear to be a git repository there. Ask, Would you like to Creator? Was there here seeking District creator? Repository on. We can leave it with the name PHP primer he the path and then just click create repository No one's. That process is the new man. It's an extra directory. You might also see additional files, but some of those are actually get related. And if you have hidden fast turned on, then you'll start seeing some other files that you probably did not create. But that's fine. It's also that the server from guitar can communicate with your local machine. Now the next thing that we want to do is actually publish repository, so I'm going to click publisher positively, which will actually send to get up that this repository should be added to my account. So I go ahead and click Publish Repository, which will then confirm with me the name that I intended toe published on guitar on. Also, if I want to keep it private are on. Take this because I want that if you stumble across my page, then you can have access to record and then click publish depositor, which will then create a synchronization between my get library here on the one on ghetto. So if I log in to get hope through my browser and refresh, then I should see a folder named Get Well Petri Primer, which will contain all off the files that were in my directory. No one's again. Here's a practical example off why I Get Top is important to have, especially in a team setting. If I needed to modify one of these files on, I go back to my side and let's say I did not want this button or I wanted an additional buttons. So whatever modifications are making and I'm going to be this one primary on. Then I went to meet this one success All right, on going to save my changes, I'm went toe. Verify that these changes are in effect, so I have my three buttons or beautifully styled by bootstrap. Andi. Then I need to share my side off the work with my coat with Michael. Workers are my teammates. All right, so using boot, get hope. Sorry. Get up there. Stop. It actually is tracking what changes occurred. So it's showing me that these two lines of court were added on then allowing me toe actually upload. So the first thing I want to do when I upload is writer description so that my teammates can come across and see what changes I meet. Seconds. They added two more buttons on. Then I commit to master and then having committed successfully, that would have been committed to my local get installation. So then I need to push the origin and urgent is the connection to the actual get top server , which is where everybody is going to have to be connected. So I just pushed urging on what will happen is that it will handle all of that synchronization between my computer cord on the court on get abs. If I go back to get up, notice all of the sea initial commits because by default, that's what it would have sent up. But then when I refresh. I will see that index start PHP, which is a file that I modified with the tuning buttons, is going to have a message indicating the difference between this on the previous person. So once again, source control leases for version in control or we'll change controls. All right, so you make a change after, check it in, and then your teammates can come across and get the latest quote at all times on check in their court so that you can get the latest quote at all times so you can have multiple people modifying these files on as long as they check in here. You can actually use get hope, the fetch. What you got fetch urging, which will say, Give me on idea of Home and the changes are pending, meaning whole different art of files that are in G tobe from the fact that are on my computer. So if George, who is my team member, made changes toe string money ons and sweet statement files then having finished urging, you will actually indicate that Hey, your files are kind of different from the last set off us that were uploaded. Would you like to get them on, Then I can just click another button, which would be pull Andi so I wouldn't see pool here because I'm the little on making changes, this report. But on a team setting, he would ask, Do you want to pull on upon doing so? It would actually update your local fast with the files from the server. So essentially using get hub or like, technologies because you have other get engines off there. But get up is probably the most popular one on using. It will help you to collaborate not only with immediate team ways, but with the world. It's a cool way to share your chord with other people, and it is, ah, major problem behind the open source movement. Nobody's Andi. I urge you to get involved, start building pet projects and sharing your coat with the world, getting positive and creative and useful feedback with your methods. Andi, just have fun. No, essentially, if you stumble across this on my profile, Traore William Speech Be primer and you want ideology for yourself. What you can do is actually go toe click on the report because I didn't make it private, and you can click clone or don't Load, which will ask you if you want to open in their stop on, then further Clooney to somewhere Or do you want open it in Visual studio, which would launch Visa Syria, provided that you have it on with the court. Or you could use this link to clone it to your machine if you're going to use command line or even the desktop, Or you can just don't know the ZIP file on zippity er one or zump server on did use it accordingly. So there are a number of ways you can actually get this court from GI Tub from my profile to your machine. I will be enjoyed this video, and I hope you learn something new as always. If you have any questions or comments, feel free to drop me a line and let me know. 17. Publish Final Website on Heroku: Hey guys, In this video, we will be deploying or PHP primer websites. Toa hero cool on will be doing that by synchronizing it with our gets hope repository. Now just a reminder. Hiroko is Web hosting platform. What they do is offer platform as a service where they contextualized the hosting offering based on the type of cold you upload. So on the Web site, which you can get toe Teruko dot com, you notice that their advertising support for quite a few languages so far we have no Js ruby Java PHP python Go on. Some other ones are So the fact is, you just speed up what you call a bucket on you. Put your coat there and they do the rest Infrastructural e the comfort of servers in the back in. You don't have to worry about any of that. You just put your side there, and with very minimal effort, you can have a website up and running on hair. Oh, cool. If you haven't already done so you can firstly navigate to Hiroko dot com. Andi create on a cones by clicking Sign opened. It's a relatively simple process to get signed up just a bit off information here on then you already. And if you already have, your county can just go ahead on and log in. No, when you log in your lead to your dashboard where you would see all of your applications. If this is your first time, then you have an empty dashboard. It's not my first time because actually have deployed things here before. Andi, even if you don't have anything, that's fine, because we'll be doing a fresh one. No, anyway, so the first thing you want to do is click new on. Then we're going to create on up next. You want to give your up name with your up? A name on the thing is that for the free distribution off this order for use off Hiroko, you're going to get a sub domain meaning whatever your app name is dot Hiroko up dot com. So, in other words, you can use the exact up name I'm going to use here on. I'm just going to use an up name that I think it doesn't exist already. So you're up. Name needs to be unique. What you can do to probably personalize it is put your name on it, so I'm just going to say Ph B Dash primer bash on many Mr If someone's going to see a trip on that is available. So if you put in one that is not available once again, just try and put something there toe personalize it so that you can share with others, and it would automatically innocently figure that it's your own. All right, so PHP dash fremer that trip that that's true. That's what I have on that is available on. I can leave my reason on the U. S. But if you're closer to Europe, then you can talk about that as you need toe on. Then I'll just create an up now. Having done that, I'm led to this page where they're giving me deployment guides and asking me if I want to add a stop pipeline. So I think pipelines will start to cost money. The next section asks us, What method do we want to use the deploy so we can use the hero could get cli commands Onda we would have gone through using the git commands from command from from the gets interferes the cli on the commands are pretty much the same You just long in which this would prompt you to actually put in your credentials in the command line on. Then you go to your project where it would be so that would be c slash zom slash HD doc slash your folder are our whatever it is in your context on. Then you get in it on. Then you add what you call a remote, which is like a connector. So this book it or this up space that we just created on then the next you commands would actually just synchronized between your existing get project. Andi. Heroic. Oh, so it's just like pushing things to get top using your command line interface. It's the same concept pushing things toe Hiroko using that command line interface. So that's one way you can do it. If you choose that method, that's fine. Uh, creates another video where I do it that way. But for this video, we're going to choose another method, which is toe connect to get up before I move on, though if you would have already added your project ticket hope, it means that you already have the git repository existing are etc. Are he already ran the gettinit. I already synchronized with ghetto another these things. So you would have already created some git repository inside our project so you wouldn't have to go through all of this, I think. Well, you would have to go through this, but then what you would do after that? It just had the remote. So they promoted just the connector. So I think right now the remorse would be origin to connect it to get up. Then you just had another remote called PHP primer. All right, well, yeah. So, essentially, that's that's what you would do that using a command line interface. And of course, after you don't want an install, that command line interferes. Connector are. But then today, we're going to be using get up. So I just click get top contact with Get up. Sorry on then. I'm already logged in. So if you're not loved being, then you can just connick still your repository here. I mean, I'm already loving, meaning I'm already loved being to get up in my browser. So you just log in to get up through whatever interferes there alot you hear on then Once that connection is established, they will ask you which repository would you like toe deploy. So the proposed turned out We have been working with his speech be dash primer. So I just stopped that in search. Andi, it's going to bring back that repository and then I'm just going to see connect No one's That connection is done than this whole section changes. To show that on, I can actually see all of the activities on that repository So we would have uploaded our 1st 1 and then we changed something else. Just the show. Just show how we synchronizes get up. So as many changes as you commit to your guitar repository, they can be viewed right here in heroic. You also know the next section talks about automatic deploys. So each time you upload to get up you or your team member, you upload to that what we call the master branch, meaning the central place where everybody is called comes together to make the final product. Then you can actually enable automatic de place. As soon as you publish something to the master branch, it will automatically updated here on heroes. They wouldn't have the come back here and repeat this process each time. Now, this has you have to be very careful with this off course because the good programmers or developers don't publish things. The master, unless they have tested it and it has gone through all the quality checks on, then Master represents the final product. So if you're experimenting with something, then what you do is create a branch on then you extra in all your experiments on this branch on. Then you request your team lead toe, consolidate this brunch into what we call the master branch are. So if we enable automatic deep lies and we see always deploy the master branch, That means that it's going to assume that one something hits the master branch. This is no very, very, very quality assured version off the software and that is what you will make available to the public. So you have to be very careful on deliberate with with your master branch and especially if you're going to enable automatic deploys. Well not went to enable automatic deploys. I'm just going to manually deploy so manually go down to the manual deploy section on. Guy will see, I want to deploy the massive grants. 11. We have looked at hotel branch and merge in get as yet on that's going to come up, but for no, we can just manually deploy. So deploy Branch and then we give it a few minutes or moments and you see that it's kind of doing some stuff. It's getting all the libraries, and we give that a few moments to finish. All right, so, no, it's successfully deployed. So if you see a green tick here, that means it was successfully deployed and you're good to go on. Then the next step would be to view your up second district. This on that will launching another top your website that you've been working on. So in this case, we've been working on Petri premise that the most elegant website it's just something to get us off A with all the basic Ph. B court cords and commands. But let's just take a step back and pretend that this was a real website. You just built a site in PHP. You have all the pages and wired up everything. Your navigation, your bootstrap. You lay out everything on with just three steps in literally less than five minutes, you know, have it on the Internet. So that is my address on the internet for this up. And I'll leave this up up so that you can type it in your browser when you're watching this video. Onda bro's toe my up. All right. Now what I'm going to do it is me at on adjustment of this site and obvious enough adjustment so that we can see the difference between what we've changed on our computers. What we commit to get up on, then hall, we update it's here on Hiroko. So no, I bring up my cold file on. I'm just going to create on anchor Taj right here underneath all these buttons. They can do this with me on. I'm just going to meet this one. Navigate to herro who dot com on, understand, to put in my age, ref on one thing to note with the external links I always put in the fully qualified http s if necessary, colon slash slash website dot com. All right, so that's one thing that I always try to do on then, since they're using bootstrap. The great thing is that we can actually style or ankle tag, and I'll just take a preview off this quickly. So this is what it looks like. All right, so it's just a link. But then if I wanted to look like one of these buttons, I can actually add all of this CSS to it, so I'm going to make it are readily car. So the bootstrap class for a red button would be I think it is danger. Andi, if I go back and take a look. Refresh on. There we go. So my link No, looks like a buttons. You know, you don't know which one is just about now. Which one is just the link? So if you want your links to look like this, then you can actually use all of the button classes the same way I know just the verify that my link works when I click it. It shouldn't ever gave me a way to Hiroko dot com on. I'm going to make one more adjustment because I don't like when a button navigates away from my website, someone's going to see a target. So this is another instant HTML attribute that you can use on this one's this target on the score. Blunk as the value on With that done on, I'll just refresh again. When I click, it will always open up. That content in another tub on my website will remain. All right. So this is the adjustment that we just made toe our website on. I'm going to look back at Watson on Hiroko and obviously haven't pushed anything new. Said the old version is still on hero. Cool. So my first art off business is toe obey it, my repository. So I'm going to bring up get hub quickly. So I'm opening up my get top desktop up on The first thing it shows me is the fact that I have made a change to my index dot PHP and it highlights the chain. So for as many pages and as many changes as many pages as you have, and as many changes as you're going to me get up will always show you what was done. Onda ask you what you want to do with it, right? So I I'm just going to say added link toe Hiroko All right, so when another developer comes along, he can see exactly the change that I at least claimed to have me. That could mean the change. And it wasn't done successfully or whatever, but at least for accountability. Each person gets requires that each time you're going to check in a change, you have to state what was done. It might give you a default, but I like to be very specific so that other people can come and benefit from my version or account off the events. All right, so then I just go ahead and commit to master right on that Step one. So that was me committing to my local git repository. No, I need toe. What we do, we'll call push. Origins are earlier I talked about the promotes or the connectors, the connector. Forget Toby's usually by default origin. The connector for their oco is relative to your up, or I think, while hero, who is what they call it. But I'm just doing that. You can have multiple connectors, so I'm just going to push the origin on. This will take a few minutes, depending on the speed of your Internet on home. Any changes your checking in on this is done. All right, so if I goto get top dot com I had my profile open on. I looked in PHP primer. Then you're going to see that I made a change to in experience and that is the last change one minute ago. Are they always kind of gives an indication as to what was done toe what file? Andi, if you're working in a team, it goes as far are saying who did it art. So the next thing would be to actually synchronize that with my hero Cool website. So if I go back to my hair Oh, cool website and I refresh you notice there is nothing that's changed because one I didn't enable automatic deploys. So that's what off the things that automatic deploys would do. But once again I'm I There are dangers in doing it that way. You have to make sure that your qualities always on fire. So for a personal project, sure, but I'm not going to do it in this video. I'm goingto no go and deploy branch again on by clicking Deploy Branch is going to go and get the latest set off us from this branch in ghetto on run off updates on in a few moments . That should be done on when I view my sight again. It no has the latest version off. What off? What? My site is all right. So No, I have this one. So if I go back and make a change and for as many changes as I'm going to make, I will check them into ghetto. Andi, I encourage you in a team setting toe. Always check things into ghetto. Andi. You could designate one person who is in charge off handling the deploy and deploy should only happen after this one person. What? It's the technical lead or chewy personal or your develops person after they have seen untested and on their quality check to make sure that everything is still in order. Whatever was working still works after your changes on whatever it is you claim to have change actually works. Then you deploy here off course machinery can be set in because you see that they're asking if you want to wait for CIA to pass toe to deploy. So their number of things that go into the automatic deployments on this video is not going to cover all of those little things. So that's why I'm avoiding using the automatic deploys. But at least from this video, you know how to get your court from your machine into a central repository where all changes can be made can be stored on gloved aan den ho toe deploy to herro coup for the wider Internet on. Like I said, you would get a supplement on your side, so or you get your set on a sub to meet another. So you have whatever the APP name is. That's Hiroko up dot com on you can actually go ahead and p for a custom domain if you are at the stage where you want to do that. So now I'm just going to give you a tour off the other tabs quickly. So from the overview tab, once they're have the up selected angles, overview top there, sure, you that you have a dollars a could install So, like a my SQL database that will be an Adan on. They give you a little little upstart, you can just put into your project on just pay a monthly fee so you don't have to buy one time. If you don't have all that money, just be monthly for the use of it. The diners would be like, How many instances off your website? So maybe no, you only have 50 users. It's fine. But when you scale so 500 users and you probably need to add more Dino's, they can handle that increased traffic on Then you might not be the only person working on your side, so you can actually manage the access to the site or to your up Andi add collaborators. So each time kind of speaks directly to that. So to add more diners off course, that's going to cost a bit off money. Deploy. We just went through that metrics. You have the idea credit card, so you can actually view the metrics of your side. See the peak usage, the baseline, those kind of things. The activity shows, I said earlier, All off the changes being made so you can actually roll back to hear if needs Visa may be deployed on when it went into what you call production, which is the actual sites accessible over the Internet. It had some errors, and bows and Sunseeker actually just roll back toe the point in time where you know, these issues were not while you work on it. So heroic all makes that very, very easy. And it's almost transparent to the user. Um, access, That's the AB. More collaborators on then in settings is where you can edit or change the name of your up . Once again, the up name has to be available. For that to occur. You can look at some other little in for information on boats. What kind of stuck on deceit automatically detected the framework needed home its size You have available Teoh your report that it is currently synchronizing with on the what you call a get remote for the heroic connector on you can actually from here, get that dough mean Andi on SSO, sir. So you can actually do everything here. It's like a one stop shop. You don't have to run to go daddy and grow there and go there. You can do everything here off course You may want to shop our own for costing on. Then if I wanted toe transfer ownership, I could actually just choose somebody else. Maybe another collaborator. I'm no longer team. Lead somebody else s team lead, so I can transfer ownership off it, so them there's also a maintenance mode. So maybe while system is being worked on are working off the books, you can put it in tow maintenance mode, where it is not accessible over the Internet. All right, so you see that they're warning you it will be unavailable on. I can go ahead and any bladder cancer that all right on then? I didn't know it all. You can always delete the up on. They tried to ask you. Are you sure? Andi, you have to re type this soul. It's us. Were very, very, very deliberate efforts to delete this up. At which point you would have lost all off your content from Hiroko Onda, the actual Contino space. So that's it for today on hold to get your up onto Hiroko and what heroic offers. If you have any questions or suggestions, feel free to drop me a line. I'm goingto go ahead on and create another video where we look at more things on more possibilities