Introduction to PHP

We thought of giving you a very basic introduction to PHP before actually going through it’s different topics one by one.

PHP is an easy to learn language and we personally suggest learning PHP immediately after you are through C/C++ and before you start with any other programming language such as Java or .Net. But before that, you must also have a working knowledge of basic HTML tags and writing a CSS file. PHP is very interesting and I assure you that after learning it, you won’t ever want to switch to any other programming language unless you deliberately want to.

When we hear the word PHP,  the first question arises what is PHP? PHP stand for Hypertext Preprocessor. PHP is a server side scripting language, which helps us in creating highly dynamic and interactive web  pages. It has variables, functions, arrays just like other programming language C, C++, Java, etc.

PHP is a scripting language just like Javascript, as it does not involve any separate compilation process. It doesn’t mean that the PHP code doesn’t compile at all. It actually does! Just that everything happens on the fly. Javascript Engine is with the browser, while PHP Engine is with the server.

Let’s check out a very simple program in PHP.

PHP code starts with <?php tag. This tells the PHP engine that it is the start of the PHP code.

In PHP, comments are written with “/*  */” or “//”.  “/*  */”  is used for multiple line commenting, while “ // ”  is used for single line commenting, as you can note in the above code snippet.

echo statement is used for printing values.

In the code snippet above, $str is a variable. Variables in PHP start with a dollar ($) sign, followed by name of the variable. We will get to know more about its usage in the upcoming articles.

We can also use print function instead of echo.  ?> tag tells the PHP engine as the end of  PHP code. Saving the above piece of code in file with extension .php and run it on the configured Apache Web Server.

The output of the above program will be :

Receive our updates to your inbox

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.