Getting Started With PHP
Step 1 : Install PHP
To install PHP, the simplest way to do this is to install an AMP [ Apache, MySQL, PHP ] software stack. It is available for all operating systems. There are many AMP options available in the market that are given below:
- WAMP for Windows
- MAMP for Mac
- LAMP for Linux
- FAMP for FreeBSD
- SAMP for Solaris
- XAMPP (Cross, Apache, MySQL, PHP, Perl) for Cross-Platforms
If you use Windows platform and don't want Perl and other features of XAMPP, you should always go for a WAMP. However, if you use LAMP for Linux and MAMP for Macintosh.
Download and Install WAMP Server
Click me to download WAMP serverDownload and Install LAMP Server
Click here to download LAMP serverDownload and Install MAMP Server
Click here to download MAMP serverDownload and Install XAMPP Server
Click here to download XAMPP serverHow to install XAMPP server on windows
We will learn how to install the XAMPP server on windows platform step by step. Follow the below steps and install the XAMPP server on your system.
Step 9: XAMPP is ready to use. Start the Apache server and MySQL and run the php program on the localhost.
How to run PHP programs on XAMPP, see in the next tutorial.
Step 10: If no error is shown, then XAMPP is running successfully.
Step 2 : Run PHP code in XAMPP
PHP programs can be written on any editor, such as - Notepad, Notepad++, Dreamweaver, etc. These programs save with .php extension, i.e., filename.php inside the htdocs folder.
Generally, a PHP file contains HTML tags and some PHP scripting code. It is very easy to create a simple PHP example. To do so, create a file and write HTML tags + PHP code and save this file with .php extension.
Example :- HelloWorld.php.
As I'm using windows, and my XAMPP server is installed in D drive. So, the path for the htdocs directory will be "D:\xampp\htdocs".
PHP program runs on a web browser such as - Chrome, Internet Explorer, Firefox, etc. Below some steps are given to run the PHP programs.
Step 1: Create a simple PHP program like hello world.
Step 2: Save the file with hello.php name in the htdocs folder, which resides inside the xampp folder.
Note: PHP program must be saved in the htdocs folder, which resides inside the xampp folder, where you installed the XAMPP. Otherwise, it will generate an error - Object not found.
Step 3: Run the XAMPP server and start the Apache and MySQL.
Step 4: Now, open the web browser and type localhost http://localhost/hello.php on your browser window.
Step 5: The output for the above hello.php program will be shown as the screenshot below:
Most of the time, PHP programs run as a web server module. However, PHP can also be run on CLI (Command Line Interface).
Now when you know the basics go ahead and Create Some stunning and innovative PHP Programs to Amaze the word. So if you want us to write Another Article for this Topic Explaining more in thorough detail you can always comment also Also, make sure to follow us on Instagram and Facebook or subscribe to our newsletter to receive Latest Updates first.
Peace!!!
No comments
If you have any doubts, please let us Know.