1. PHP & MySQL Enabled Server
As I already explained here, here and here, PHP is very easy to learn. However, because PHP is a server-side program, and so, it has to work and perform on a PHP-enabled server, you can not run your PHP scripts on an ordinary personal computer like your desk computer or laptop. You have to have access to a PHP-enabled server.
If you already have a web hosting service, you can use it to test the PHP scripts you create. If you do not have a web hosting service, then you have to create a PHP-enabled server for yourself, and this can be done through installing PHP and a web server application on your personal computer. This can be done through installation of a web server (like Apache), PHP and MySQL on your computer. However, there is an easier option for you which is installation of an all-in-one software instead of all these. There are some all-in-one software for windows. I recommend XAMPP which can be installed on Windows 2000, 2003, XP, Vista and Windows 7.
XAMPP installation will add so many tools to your computer: Apache, MySQL, FileZilla FTP Server, Mercury Mail Server, Tomcat, PHP, Perl, phpMyAdmin, Webalizer and Fake Sendmail.
It is very easy to install the XAMPP on your computer. I will explain how to do it, but before that, I’d like to let you know about the Firewall.
Firewall is a software that blocks having access to a computer through the ports. It is for the security of the computer. Widows comes with a built-in firewall. As Apache and MySQL and also some of the other tools that come with XAMPP use the ports, the firewall will prevent them and they will not be able to work. The solution is that if your computer operating system alerted that the firewall has prevented any of these tools, you have to unblock them. You can change the firewall settings by going to “Control Panel>System and Security”. There are several ports in your computer. To make Apache working, you have to unblock the port 80. Also 3306 and 25 ports have to be unblocked for MySQL and Mercury Mail Server respectively. If you still have problems after unblocking these ports, you have to disable the firewall completely and see if you still have any problems or not. If you don’t experience any problem when you completely disable the firewall, it means the problem is related to the firewall, and so it has to be reconfigured.
XAMPP Installation on Windows:
1. Download the XAMPP here:
I recommend you to download the installer file, and not the zip files.
2. Double click on the installer file. It will warn you that you should not install the XAMPP in the Program Files folder because this folder has some restrictions that will make problems in running the XAMPP tools. Of course, the installer file will create a folder named XAMPP on the root directory automatically and will install the XAMPP file in that folder. So you do not have to be worried about it.
The installer file will create shortcuts on the desktop and start menu that enable you to run the XAMPP control panel.
When the installation is finished, the program will ask if you want to run the XAMPP control panel, and if you click on Yes, the control panel will be opened:
On the XAMPP control panel click on the “Start” buttons in front of the Apache, MySQL and Mercury to start these tools. It is the time that the firewall will alert you that these tools are blocked. You have to click on the unblock button.
You are done with the installation. Now your computer is PHP, MySQL and Mercury Mail Server enabled and it can work exactly as a PHP-enabled server. It is what the PHP needs to perform.
Now the question is where you should place your PHP files to run and make them working. It means, when you create a PHP file like index.php, where has it to be placed on your computer in order to make it work?
After the XAMPP installation on your computer, the C:\xampp\htdocs folder is where you have to place the PHP files. I recommend you to create a separate folder in the C:\xampp\htdocs folder for each of your projects.
Now that your computer is PHP-enabled, are you ready to create your first PHP web page?
I know that I have not taught you to code in PHP, but I just want to show you how your computer works as a PHP-enabled server after the XAMPP installation. Later on, I will teach you to code in PHP in details. For now, just please follow the below instructions:
1. Open the C:\xampp\htdocs folder.
2. Create a new folder in it and name it Project1.
3. Double click on the Project1 to open it, so that you should be here now: C:\xampp\htdocs\project1
4. Now, open a Notepad window by going to Start > All Programs > Accessories and clicking on the Notepad shortcut.
5. Copy and paste the below code to the Notepad window you just opened:
6. Click on “File > Save As” and on the “Save as type” choose “All Files”.
7. In the “File name” enter the index.php as the file name and click on the save button. Please note that you have to save it in the C:\xampp\htdocs\project1 folder.
8. Now, open your web browser and enter the below URL in the address bar and hit the enter button:
What do you see on the web browser now?
If you see this, you have done it correctly and you have created your first PHP script successfully: Hello World!
2. Text Editor
You need a text editor to write the PHP codes. In the first project we did above, we used Notepad. It is the simplest text editor. However, it is not suitable for the professional programming. Its biggest problem is that it doesn’t have the line and column count and it makes it too difficult to edit the big PHP files. Instead, Notepad++ has everything you need to write the codes. It has a lot of great tools and features and still is not too complicated and heavy to load. You can download it here for free.
There are some other free text editors that you can google for and download: Crimson Editor, SciTE, TextWrangler.
There are some commercial applications with some good features, but I do not recommend you to buy them because you do have to: BBEdit, TextPad, TextMate.
3. FTP Program
If you have already installed the XAMPP on your computer, you can easily use it as a PHP-Enabled server (as you saw the first project worked on it successfully) to test your PHP scripts while you are learning and practising. However, if you do not like to install XAMPP on your computer, you need to have access to a PHP-Enabled server through FTP (File Transfer Protocol). You have to buy a PHP-Enabled hosting service and have access to it through FTP to upload your PHP files to it. To upload the files through FTP, you have to install a FTP application on your computer. There are some commercial FTP applications that you can buy, however, there are some good ones that can be downloaded for free. I recommend you to use these free applications and not to buy the commercial ones: Total Commander, FileZilla.
4. Basic HTML Knowledge
To develop web pages through PHP, you have to have a basic HTML knowledge. It is every easy to learn the basic HTML. It can be done within a few to few hours. You can buy a small HTML books and just learn the main HTML tags. That will suffice. Let me show you how a HTML tag could be used on the above project we did, just to show you what do I mean by HTML tags (in case you have zero knowledge about HTML):
Please refer to the 6th stage in the above project where we entered the below code to the Notepad file:
Now, enter a before Hello World! and after it. It will be like this:
Now save the file, enter this URL to the browser address bar and hit the enter button: http://localhost/project1/
What difference do you see now?
Yes. The sentence is displayed in bold: Hello World!
The reason is that any text that is placed between and will be displayed bold. … are HTML tags and text that is placed between these two tags will become bold.
Now that you have everything you need to start learning PHP, you can move to the next PHP training article. Find the complete list of my PHP training articles here: How to Learn PHP Programming