A Beginners Guide to Linux Programming with PHP – Introduction


Example using Nano

What is PHP? PHP is a recursive acronym stands for PHP Hypertext Preprocessor. In your hours spent trawling the Internet you have probably come across PHP numerous times. You may not know how powerful the language is, and what it can do and you may not have even seen any PHP code before now! PHP has the awesome position of being the only open-source server-side scripting language that's both powerful and satisfying to learn!

Why Use PHP?

HTML is completely static. By using and HTML, we can create dynamic sites that will change depending on certain conditions. Not to mention that PHP is powerful, scalable and best of all, free. Data-driven applications can be mashed up quickly with the built-in database support in PHP, add an excellent manual, a friendly community and a price of zero – and you've got my favourite programming language!

Setting Up Your Environment

As with all programming languages, before you begin to staring programming PHP, you need to have a development environment set up on your box. In the following PHP tutorial we will be using PHP with the Apache Web server running on Linux. However, you can just as easily use PHP with Apache on any operating system. Detailed instructions on how to set up a LAMP (Linux, Apache, MySQL, PHP) development environment on are here, in another of my articles.

Learning Some Syntax

PHP code sits inside a page with the HTML, as with HTML it is made up of plain-text. Therefore, a page that shows "We are about to learn some awesome PHP skillz (yes, skills with a z)" would be inside an HTML page named filename.php like this:



<title>Bright Hub Article</title>


<body> <p>That is some simple PHP code below:</p>


echo 'Hi, my name is Josef';




See? The HTML is rendered as HTML and the code between the <?php and ?> gets executed as PHP.

You may notice some instances where the "php" after the question mark is missing. This is a lazy practice known as "PHP short tags" – full tags should always be used! Also, PHP statements end in a semi-colon, however, a semi-colon is not required to terminate the last line of a PHP block, as the PHP closing tag ?> contains a semi-colon.

Next Time

I hope you enjoyed this brief introduction to PHP and that you come back for part two! In the next article we will take a look at more statements, how to comment and execute your beautiful PHP code!

This post is part of the series: A Guide to Linux Programming with PHP

In this series of articles I’ll be teaching you the basics of using PHP, and showing you why I think it’s the best language for web development. There are no pre-requisites for your level of knowledge, other than that you can understand basic HTML and are willing to learn.
  1. A Guide to Linux Programming with PHP
  2. A Guide to Linux Programming with PHP – Commenting and Executing Code
  3. A Guide to Linux Programming with PHP – Variables & Data Types
  4. A Guide to Linux Programming with PHP – HTML Forms and PHP
  5. A Guide to Linux Programming with PHP – Arrays
  6. A Guide to Linux Programming with PHP – Associative and Multidimensional Arrays