Tuesday, October 22, 2013

Introduction to PHP and basic setup

PHP is one of most commonly used programming languages for developing dynamic websites, and this is the main concept that we should focus when learning PHP, everything in PHP is about making a website dynamic.
This is because PHP is a “serverside” programming language, which means that it is executed on a web server, and then it generates html code that will later be downloaded into the user’s webbrowser. This is usefull for websites and allows the development of web applications, content management systems, and more, software like wordpress, joomla, or drupal, are developed in PHP.
Next I’l leave you this video as an introduction to the PHP programming language, and a basic setup.
Introduction to PHP video tutorial

Requirements to do some programming in PHP

As a start, to develop using PHP we require the installation of a web server including the PHP interpreter so our code may be executed, for this I would recommend using a program called XAMPP, which you can find at http://www.apachefriends.org/en/xampp.html and that will properly install apache, PHP and MySQL(for using databases with php) in windows, mac or linux. To set it up you may find all the documentation at the xampp’s site, or you can watch the video above to get an idea.
The next thing that you will need is any text editor you like, and a web browser, I would recommend using sublimeText (available for windows, mac) bluefish for linux, and google Chrome as a web browser.

First program in PHP, a simple “Hello World”

Now that we are ready, we can type in this code into a .php file, and see what happens, this is the hello world program that prints a simple message using php.
1<?php
2 
3echo "Hello World!!";
4 
5?>
Save this in a .php file using a text editor, store it inside the htdocs directory inside the XAMPP installation or your web server.
Access it by typing “http://localhost/yourphpfile.php” on your webbrowser and it’s don!!
Congrats on making your very first php application!