 Hey everybody, this is Brian. Welcome to the 6th LAMP tutorial. Today we're going to be showing you how to edit a PHP file. And we're going to actually write our first one I might add. First thing we want to do is go out to var, dot, dot, dot, right click, go to properties and then go permissions. Yours probably says root and root. So when you open up like g-edit or a text editor or something, you go to save a file out in this folder which is the root of your web server. You get it cannot write the folder or access to night or something like that. But we're going to fix that. Got the directions right here on the screen. I'm a big fan of Google. Press Ctrl Alt T to bring up a terminal window. Get that somewhere where we can juggle these windows around here. You don't really need to know what any of this stands for. Really, honestly, when you rent a server, this is all done for you. You don't have to worry about it. sudo and user. What we're going to do is we're going to add our current user, whoever you are. I should back up. If you don't know who you are, it's like, who am I? We are tests. So we're going to do sudo add user. The username, in my case, test to the group, dot, dot, dot, data. Now I get an error message already in group because I've already done this. I'm simply showing you how to do it. Then you can go sudo chown or chown which stands for change owner. Then we're going to say dot, dot, dot, data. Fair, dot, dot, dot. Now why did we do dot, dot, dot, dash, data twice? Well, the first one is the user. The second one is the group. In Linux, you have a user in a group. You don't really need to understand what those are. This is just file permissions we're setting at this point. sudo chmod. And then we're going to set the permissions on the directory itself. Now that we've done that, we can actually modify the files out in that directory. Now I want to talk to you real quickly about IDEs and editors. There's a ton of PHP editors out there. If you just go to Google and type in PHP editor, you will get so many hits it will completely boggle your mind. I mean, you will have so many choices. I mean, look at the number of choices here. Yep, a lot of them. Very rare. I mean, if you've watched any of my tutorials and other languages, it's very rare that I really put my seal of approval on a product. It's got to be really outstanding for me to do that. I searched high and low. I've looked at other, like, Genie. You can go into the Ubuntu Software Center and look for PHP and Genies out there. There's a bunch of others. There's even Eclipse. Eclipse has a, what is it, PTT. I could not even get PTT to run. I sat on the phone for an hour with a Linux guru friend of mine. I could not get the thing to run. I promised you at the beginning of these tutorials I would do this so you could do it dirt-free without paying a dime. That still holds true. Go out to ActiveState.com and you may have to go to Developer Tools and then Komodo. They have two versions of this. They have the IDE, which stands for Integrated Development Environment, and Komodo Edit. What's the difference between the two? As you can see from this little matrix here, the edit only gets these first four. We say, oh, it's only the first four. You know what, those first four are pretty much what most of the other editors out there have. It actually has a little bit more, in my opinion. The IDE has, look at all these. Wow. If you ever get into professional development, source code control, synchronization, profiling, database explorer, publishing. These things are real lifesavers, especially unit testing. Oh, don't get me going on that. Now, the IDE does come with a price of $295, and I know probably half of you just fell out of your chair having a heart attack. I've plucked down about $3,000 for Microsoft Visual Studio before. That's like buying a car. So, for me, $300 while painful is still worth the cost. Now, I'm a very blunt and honest person. I did email ActiveState and say, look, I really want to use your free version for these tutorials that I'm going to be building on PHP. And they said, why don't you use the IDE? And they gave me a license for it. Now, disclaimer time. No, I cannot give you my license. And no, do not email them asking them for a free license because you watch these tutorials. But if you do buy Komodo IDE, which you don't have to, but if you do buy it, do mention me because I'm sure they're wondering how many people are watching these videos and how many sales they got, et cetera, et cetera. Like I said, it is extremely rare that I endorse a product. And I'm not getting any kickback. I know some of you are saying, well, you got a free IDE out of it. Well, I got the IDE before I even made the tutorial, so I could have just taken the IDE and walked away. But I'm not. I'm actually making the tutorials because I really, really like this program. I'm going to get off my soapbox. IDEs become a religious war. Some people love Eclipse. Some people love NetBeans. Some people love Genie. Some people love Komodo. Some people love using Vim or Notepad or G-Edit or whatever you're using. Find something that works for you. All right. So I have Komodo IDE 7.1 in case you are watching this tutorial and you're on a newer version. And whenever I do a Komodo specific feature, I will try to note that I'm going to do a Komodo specific feature, File from Template. You can just do File New in whatever editor you have. I'm going to have to set the directory here. And this is going to be very conditional on what editor you use. So if you're following along at home and you're very new, I would recommend you go get Komodo IDE or Komodo Edit. Komodo Edit being the free one. Very good program. I'll call this File 1, PHP. Notice the .php extension at the end. I'm going to click Open. And here is our first PHP file. And that's all of its glory. Now, that start bracket and that end bracket. The question mark, question mark. Anything between those two is what's called a code block. So this is a block of PHP code. The reason why I like using an IDE is because it really saves time. You notice as I'm typing, it's making the commands for me. Just cut my work in half. I didn't type all that stuff out. I just did the first few letters of each one. Now, some of you already know that's the beginning of an HTML document. I'm almost going to say that HTML is a prerequisite for these tutorials, but I will explain things as I go. I do have an HTML video series out on my YouTube channel. So if you're watching this, click on my channel and then go watch the series. Anyways, there's your start tag and your end tag. Everything in HTML has either a tag or a block. If it's a tag, there's a start tag. You know it's a start tag because it's brackets. You know, this is an end tag because it's a bracket slash and then bracket. And inside is the tag itself, HTML, HTML. So we're turning HTML on, turning HTML off. And here's the body. The body is whatever is in the body of the document, what you're actually viewing on the page. Turn it on, turn it off. And then here's our code block of PHP. So we're going to write our first PHP script. Notice the syntax highlighting. Echo, we'll just print out whatever we put on the screen. And we're going to do quotes. And then hello, comma, my name is, and then whatever your name is, my name is Brian, by the way. Save your work by pressing control S. And then you can either open a web browser. And let's actually do that. So I can show you how. And then what did we name that thing? One dot PHP. There we go. Hello, my name is Brian. That's one way of doing it. A lot of IDEs, actually not a lot of them. Komodo has this and I love this feature. Preview buffer in browser. And you click that little guy. And it says, how do you want to view this thing? You say HTTP. Maybe if I could spell. Like I said, maybe if I could spell PHP. Preview. Ta-da! I like that feature. Another cool feature is when you modify it, you press control S to save. Watch the preview at the bottom. Automatically updates it for you. That is some very rapid prototyping right there. Anyways, thank you for watching. I hope you found this tutorial educational and entertaining. And if you're considering an IDE, I would check out Genie. I would check out Eclipse P-T-D. I would definitely check out Komodo Edit and especially Komodo IDE. You're under no obligation to buy anything. Remember that. But I will say I'm very impressed with Komodo IDE. And they not giving me a free version. I'd probably be plucking down the money for it. It's $295 I think. Let's go out. Let's go find out real quick. Komodo IDE. Let's see. Okay, Komodo IDE. Single license including upgrades and support. $382 total. No support is $295. I know some of you, especially outside of the United States, are probably bogging at that price tag. Let me tell you. $300, $400 is nothing. I bought Visual Studio for $4,000 before. And that was like buying a car. $400? I mean if you learn PHP and you do a website for somebody, you can make that your first website. So like I said, I'm not getting any kickbacks. I'm not getting any royalties from this. Yes, I will admit they gave me a full version of the IDE. They didn't have to do that. I commend them for that. If you're under no obligation to buy it, I would definitely check it out. I feel very strongly it's one of the better PHP editors out there. And for me, it's cross-platform. Because I work in both Linux and Windows. And so being cross-platform is very important. You can follow along in these tutorials in any IDE. You can even use Notepad or Gedit. There's no requirement saying you have to use specifically one type or another. So that's it for this one. Thank you for watching.