Getting started with PHP Development
PHP Development is most used technology when it comes to developing websites or web apps.Website development consist of two main component
- 1. XAMPP – AMPP on XAMPP Stands for Apache, MariaDB, PHP, Perl and X stands for any platform or Cross platform (OS like Windows, linux or OS X)
- LAMP – LAMP stands for Linux, Apache, MySQL, and PHP. So it is only built for Linux.
- WAMP – WAMP stands for Windows, Apache, MySQL, PHP. So it is only for Windows.
Installing XAMPP (Web Server/Localhost) on OS X (Maxbook Air 13.3) or any other platofrmAs I have Macbook Air, I will be guiding you to install XAMPP on Macbook Air but you can use same instructions with Linux as well as Windows.
First go to https://www.apachefriends.org/download.html and download XAMPP based on your OS and hardware architecture. I am going to download following version “7.0.26 / PHP 7.0.26” which you can directly download by clicking here.
Once you XAMPP is installed just click on it and installer wizard will start. Follow the steps as they are very easy.
That is really simple isn’t it. Let get start with Hello World application.
Run Hello World in PHP (XAMPP)Locate “htdocs” directory in your system. It most likely will in following address /Applications/XAMPP/xamppfiles/htdocs/ if you are OS X user if now you can use search on window or linux to find. Once you located the folder you need to create a file with .php extension. .php extension is important because it tells server to execute this file as PHP so if you have .html extension then all the code you write on php will simply print instead of executing through server. Don’t worry you can use all html elements inside .php file. I have created hello.php inside htdocs folder and now here is code to print “Hello World” <?php echo "Hello World";?> Code explanation:-
- “<?php” simply tells server that it’s start php PHP code for execution.
- “?>” is to instruct server that php code is done so stop execution.
- “echo” is pre-built PHP function which instruct server to print anything, which need to be quoted if it’s string.
- “;” semicolon is used to end a statement in our case we end echo function so server knows where the print statement ends. There will a lot of use of semicolon so be careful else you will see error.