Lesson 9 PHP - Introduction
Lesson 9 PHP - Introduction
9.1 Introduction
PHP (Hypertext Pre-processor) is a web server-side programming language. It enables
developers to build web applications that interact with databases.
PHP isn't the only code that involves server-side scripting, and server-side scripting isn't limited
to websites. Other server-side programming languages are Python, Ruby, C#, C++, and Java.
There are many instances of server-side scripting, which provides a customized experience for
users.
9.1.1. Install PHP
To install PHP, we will suggest you to install AMP (Apache, MySQL, PHP) software stack. It is
available for all operating systems. There are many AMP options available in the market that
are given below:
o WAMP for Windows LAMP for Linux, MAMP for Mac SAMP for Solaris
o XAMPP (Cross, Apache, MySQL, PHP, Perl) for Cross Platform: It includes some other
components too such as FileZilla, OpenSSL, Webalizer, Mercury Mail, etc.
9.2 PHP Syntax Rules
1. All the php code in a php script should be enclosed within <?php and ?>, else it
will not be considered as php code. Adding php code inside the PHP tags is
known as Escaping to php.
<?php ... ?>
Apart from the standard <?php and ?>, you can also use the Short-open tags:
<? ... ?>
Or use the HTML script tags, like we do for adding JavaScript code in HTML
document:
<script language="PHP"> ... </script>
2. Every expression in PHP ends with a semicolon;
3. Commenting PHP code: Both single line and multi-line comments are supported
in PHP. For single line comment, we can either use # or // before the comment
line. For example:
4. PHP is case sensitive, which means that a variable $tiger is not same as $Tiger.
Both of these, represent two different variables here. But all the predefined
keywords and functions like if, else, echo etc are case insensitive.