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
Frontend as it sound is all about the appearance and interactivity of web pages and the backend is about processing data, logics.
Let’s consider an example of a contact form:-
How form will look is frontend and how the data of form will handled after submission is work of backend technology.
How to get started with PHP
You can either install Apache or Nginx either one can be used to run PHP.
There are some pre-built solution to run a web server on your computer or laptop, here are those:-
- 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.
Note – XAMPP runs MySQL so don’t get confused with the MariaDB.
Installing XAMPP (Web Server/Localhost) on OS X (Maxbook Air 13.3) or any other platofrm
As 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";?>
- “<?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.
Now run php by opening following url in your browser – http://localhost/hello.php
and we are done with hello world program in PHP, after exploring a little more PHP you should follow my other article on how to install wordpress on localhost
Hope this article helped, don’t forget to comment, share and subscribe.