What you should know before starting?
Let's get started
To start programming, I assume that you are currently using the Windows operating system. I'm using Windows 10 - 64 bit, just right click on your desktop and create a new folder named "start". In the folder, right-click and select "Text Document" from the "New" menu to create a text file. Then rename it to "index".
Now you have a text file that you can open it with "Notepad". The extension of this file is ".txt" but in the default setting of windows, you can’t see the extensions.
First, before doing anything, you must make a change in windows to show the extension of files. Go to "Control Panel" and choose "File Explorer Option". From the "View" tab, you need to uncheck "Hide Extensions for Known File Types" and click OK.
Now again take a look at your "index" file.
You can see the extension of the file. Rename the file and change it to "index.php". Congratulations, you just created your first PHP file!
If you run this file with "double click", Windows will probably open it with "Notepad". All you need for PHP programming is the same text editor called "Notepad"! With Notepad, you can code big and complex PHP applications, but it's a bit difficult. A better solution is to use professional text editors designed for programming. Today, there are many text editors and even complex IDEs created for PHP programming you can use, but when I started 17 years ago, there weren't such things. I used to use a text editor called "Notepad ++" and still I'm using it. This text editor is a simple, free and good text editor for programming. To start, I recommend you use it, and when you become a professional, you can use other tools or maybe IDEs.
So Download and install it from below link:
After installation, your "index.php" file probably will open with this but if not, tell the windows to always use this application to open PHP files. Then open "index.php" and paste the following code to it and save the file.
As you can see, it is a few lines of simple HTML code, so, yes, you can use HTML in PHP and run it simply. Now it's time to run this file. As you probably know, PHP is a server-side language and you need a server to run it. Once again, rename the file to "index.html" and try to run it by double click. Probably internet browser installed on your computer will run the file successfully. Because we change the file type to HTML and HTML is a client-side language. But to run PHP we need a server that could run PHP. Change the file's name back to "index.php". If you have a Linux hosting on the internet, you can upload the file right now and then run it by typing its address in an internet browser like Chrome and see the result. But we want to do something this file could be run on our computer with windows so we can code and test PHP on our computer. Here a magical tool comes to help us and with installing it, we have a local server on our computer that can run PHP files on our installed Chrome. The name of this tool is Wamp Server and it’s an installable program for windows and it's free. From the address below you can download and install it:
This program will run a server like a Linux hosting on your computer that can run PHP and it's all you need to become a professional PHP developer.
After installation completed, run your Chrome and type "127.0.0.1" in the address bar and press the Enter. Yes! You have a server on your computer.
The "127.0.0.1" is running a file in a folder with the name "www" in your C drive. The folder is located somewhere like here:
Locate it and then open it. You will see some other folders and some PHP files in it. Don't do anything with them, just right-click in the "www" folder and create a new folder with the name "start" and place your "index.php" file in it. Now open this address in Chrome:
Bingo! your PHP file ran successfully and you see the result.
From now on, all your life will be is this "www" folder. You will create new projects as new folders in this magical "www" folder and place your PHP files in those folders and then run their address in Chrome to see the results.