We thought of giving you a very basic introduction to PHP before actually going through it’s different topics one by one.
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.
Let’s check out a very simple program in PHP.
/* this is a sample program */
$str = “This is jcombat”; // initializing a PHP variable
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 :