All right guys, welcome to PHP video number one. Today, we’re going to be talking about what you need in getting started. So, what you want to do is you want to download a program called XAMPP and you can see it right here, there’s XAMPP control panel. You basically just need to go to Google. I’m not on the internet right now, so I can exactly show you but there is other videos on YouTube and you know, you can use Google XAMPP and go to their website and download the windows version if you have windows or whatever version if you have a different operating system. Then you just going to, you know, double click the icon and go to the installer. It’s really straight forward and simple. Once you get complete with that, you want to double click here the control panel, you want to try on to MySQL and Apache. So, make sure you do install those when you, you know, when you’re asked any installer what you want to install. If you do select different ones, make sure Apache and MySQL are checked on. FileZilla and Mercury, those are optional depending on what you want to do. Those are usually different things.
All right! Now, after you have installed just open up a text editor. Well, first I’m going to show you where your directories is. Go to the directory and install your program. This is—I’m not sure what the default is. I think it’s C, program files, and then find XAMPP, it will be down in the axis, just go down and then double click in there. Mine is in a special directory, Mine files, programs and then XAMPP. I’ll show you that right there. But once you’re again inside this folder it’ll all look the same, so no matter how you got here, this will look all the same to you. So, what you’re going to do is find sort of htdocs right here. You want to find this folder and double click inside that. Now, anything inside your htdocs folder can run PHP because it’s set up for that. So right now, you have the index, and that’s the default file. So, open up an internet browser and we’re going to open up Firefox because that is the one I use. Go appear in the address bar and make sure you have Apache, MySQL turned on which we did earlier in the control panel. You just type localhost.
Now, I’m a getting a dialogue prompt because I set it up to require you to name a password. When you first install it, it most likely won’t do this unless you told it to. So, I’ll just put in my information for that. And here we go, we have started up. And you’ll notice this, this is the index which you see inside your htdocs folder. Below, yeah the XAMPP folder right here, your index file because you can see up here, it’s a local host/xampp local host will take you to the htdocs and since it’s slash xampp we’ll go into the XAMPP folder. It takes you there by default when you type in localhost. So, inside your XAMPP folder, you can store all the files you want or you can install them anyway in htdocs. I just do it in the XAMPP folder. I create a folder called projects and you see a whole lot in this crap in here. If I type projects on the end of xampp, you’ll see we go to the index of the projects and here you have all my folders and stuff that I put in here.
Real quick, I’ll just show you the simple Hello World program to get you started, so just remember to store in your htdocs folder somewhere inside there or subdirectory of it and then you want to navigate there in your internet browser, and you’ll run the PHP file. But let’s get started on how to actually use PHP. What you’re going to do is open up notepad or whatever you use as a text editor and we’ll go ahead and get started. Now, all PHP files are saved as .PHP, so if you have PHP in the file and we’ll go over these in a second. If it has those in anywhere, you need to save as .PHP. That’s just the simple little to rule to get you going. We’ll save this as hello_world.php, Save as type text documents to All Files. And I’m just going to save it on my desktop for now.
Now, the actual PHP file. Now, you can end that PHP inside HTML and other things or let’s say for instance we start a simple HTML document. And you want the title to be something other than what you can normally typed in with text then you would right here in between the title tags you would open your PHP tags and you would run whatever code you want for the title. Just to be simple we’ll just echo something and echo is just typing it or writing it out, just like in those files and now go over this in a second. Oh, we’re just echo hello world and save it. Now, I’m going to see this helloworld.php file and I can't open this in an internet browser normally. I have them set opening it notepad, so I can quick edit whenever I need to run. I mean, I’m going to drag this into my XAMPP projects which is a shortcut I made to the htdocs/xampp/project photo that we went to earlier and there’s helloworld.php.
So, go into your internet browser, this is the projects. We reload this page and there’s helloworld.php. Now, appears the title, you can see index of XAMPP projects. Now, I’m going to click helloworld.php. And you can see the title has changed to helloworld. And you can see the html for that right here and we just have PHP where the title is. Now, let’s go over what it actually does. Anytime you want to start a PHP code section, you need a—oh, see what is that, less than tag, yeah. Less than or question mark and helloworld.php. After that you just go down a line or whatever, you don’t have to go down a line but it’s easier to read when you do. And type all your code out that you want PHP to execute and then at the end of the PHP, you want another question mark and then a greater than sign and that ends it. So basically, that is PHP right there. Now, anything inside of these tags will be executed by PHP and must be valid PHP code, outside of those tags you can do whatever you would normally did. So, you can type standard text here, helloworld and save it, reload the page, actually hold on a second. Oh, yes I save it to my desktop. I forgot to reedit the file. Okay, here it is, just drag it back in there, move and replace and then we’ll open up this helloworld.php.
All right! Now, when we reedit the file, you’ll see helloword or actually we got in here. So, here’s our first PHP here on the go and you can see I forgot to remove my double PHP tag up here. Save it, there it is helloworld. So, when you see helloworld it’s a standard text of html, it’s outside the PHP tags. So, you know, you see it executes normally. Now, let’s put something inside the PHP tags. Echo by the way is as I’ve mentioned earlier the way through void up things. So, just like batch files, echo is to write up things and you need to put it in quotes unless it’s a variable, if it’s—which will get into variables later but if it’s available then you don’t need it in quotes. But anything quotes is taken out as a string. So, we’ll go ahead and write up something, say “This is our first php document”, and then we’ll put a line break and yes you can echo out HTML inside PHP. So now, let’s save that and load it and you see there it is.
This was rendered with PHP including the line break on the end and then that’s just HTML. So, you can see how that works, it’s pretty simple. Thanks for watching the video. And in the next video, we’ll go over something a little more extensive.
Transcription by:
Scribe4you Transcription Services