Breaking News

Getting Started With PHP


 
Beginners guide for 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
The XAMPP includes some other components too such as FileZilla, OpenSSL, Webalizer, Mercury Mail, etc.

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 server

Download and Install LAMP Server

Click here to download LAMP server

Download and Install MAMP Server

Click here to download MAMP server

Download and Install XAMPP Server

Click here to download XAMPP server

How 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 1: Click on the above link provided to download the XAMPP server according to your window requirement.





Step 2: After downloading XAMPP, double click on the downloaded file and allow XAMPP to make changes in your system. A window will pop-up, where you have to click on the Next button.




Step 3: Here, select the components, which you want to install and click Next.




Step 4: Choose a folder where you want to install the XAMPP in your system and click Next.




Step 5: Click Next.



Step 6: XAMPP is ready to install, so click on the Next button and install the XAMPP.




Step 7: A finish window will display after successful installation. Click on the Finish button.



Step 8: Choose your preferred language.






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.


  1. <?php      
  2.     echo "Hello World!";  
  3. ?>  


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:


run PHP code in XAMPP


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.