 Well lately I've been working a lot on jquery tutorials and getting ready to move into jquery mobile Making client-side web applications, but a lot of times you're going to need a little bit of a server side Which when it comes to server side the great thing about server side is if you're the administrator on the server You can use whatever you want for server side scripts and programs you can use Bash PHP pearl Python you can even write stuff and see if you want it's it's all up to you But in most cases when it comes to server side stuff It's usually going to be a scripting language rather than a compiled binary language like C but I tend to use PHP a lot and to be honest lots of times I'll use PHP and And Bash together and I'm trying to get better at PHP rather than blending two languages together not necessarily that's wrong But it can get a little sloppy. So What I'm going to be doing here over the next couple of weeks is putting out a quick tip little things on tutorials here that this basic stuff in PHP and And So here we go the first one is we're just going to learn to read a file line by line I know I've done tutorials on PHP in the past. I did just a few a couple of years ago I don't remember why I went over so we're just going to start with some basic stuff here I'm not going over how to install PHP playing its tutorials out there if you're have a website hosted with Many hosts. It's usually enabled or enabled by a check if you're trying to get set up on your local machine It's in your repositories. Just install a patchy and PHP and you should be good to go so anyway This is a file on my local computer here if I click name list it has a list of names It's just a text file down here in the terminal. I'm in the same folder. I can cat out that file names dot list and we got names right here and So now we're just going to create our PHP file, which is Basically a repeat place if you have PHP running on your server it will replace your HTML You can still have HTML files, but if I was to do just as example Vim and I'll just call this read.php Since we'll be reading our text file and I was to come in here and I was to just put h1 Hello world Close that so it's basic HTML Save that Refresh up here, and I'll click on read PHP and you can see it works just like a regular HTML file, but I can also add in PHP tags here and anything inside these tags will actually be PHP script so I can say echo Hello world and Each line has to end with a semi colon. I'll save that Run that and you can see if we were to look at the Code here. That's what this outputs And we can also if we want to put some HTML code in our PHP code with the echo so basically echoing out that Will now make that bold so that's just a quick little intro and now we're going to go into reading files from or lines from a file and What we're going to do here is inside our PHP code Here we're going to create an object. We're going to say I'll call it lines Equals and then we're going to use a function called file Remember each line has to end with a semi colon and within the parentheses here We're going to pass the name of the file We want to read which if we look at our files here our names dot list is what we want to read so I'm going to say names dot list and make sure that that's within either single or double quotes And now we have an object basically an array at this point called lines Now we want to read each line or each item within that array So we're going to say for each all one word Parentheses and then inside the parentheses. We're going to give it our array which in this case is lines and Then as and then what we want to call the variable That's we're going to use within this loop because this is going to be a for loop for each So I'm going to say dollar sign and let's call it name because we know each line within this text file is a name We're going to give it squiggly braces here curly braces curly brackets Whatever you want to call it and then here we're going to say echo and We are going to for each line or each item in the array dollar sign name and Here you're going to want to use double quotes because single quotes would make that not a variable So we're almost done here. We'll save that and if we go back into our read dot PHP You'll see it outputted the names, but it output them all on one line Let's control you and look at the code. They're all on different lines there But if you're familiar with HTML, which I showed us at the beginning You really should know basics of HTML before moving on to a server side scripting language That HTML does not recognize white spaces or new line characters. You got to give it a tag of a new line So I'll come in here and I'll say break and And Now if we have five we've got a list and of course as I said earlier, you know, we're working with it like it's HTML So we can start outside of our PHP and we can say Give it a UL Out here close this and then instead of a line break we can say li for list And li for list there so now instead of just printing them on each on a new line We are going to refresh this and you can see they're in a list format Which is something we're going to do a lot with our jQuery mobile once we get into those tutorials So that is reading a file line by line. This is the first in my new series on PHP I hope you enjoyed it and Bunch more of these coming over the next couple of weeks and there's gonna be short little tutorials like this one In fact the next one is going to be almost identical you'll wait and see that and That will be a next trial. So be sure to check out my website films by Chris comm that's Chris with a K There should be a link in the description Also, if I did not forget there should be an annotation to this entire playlist Obviously at the time of uploading this video There's only one video in that playlist, but as I post more that playlist will be added too So be sure to check out that Annotation once again if I didn't forget to put it there If and if you're liking these tutorials on PHP be sure to give this video a thumbs up comments. Let me know Because server-side scripts are important in a lot of cases So and you'll see that as we start making full applications with JQuery and then in a lot of cases we'll be using PHP as a server-side script So thank you for watching and I hope that you have a great day You