PHP Introduction

PHP Introduction and Examples
PHP is a powerful tool for making dynamic and interactive Web pages. PHP is the widely-used, free, and efficient in developing web applications.

  1. PHP stands for Hypertext Preprocessor
  2. PHP is a server-side scripting language, like ASP
  3. PHP scripts are executed on the server
  4. PHP supports many databases (MySQL, Oracle, PostgreSQL, etc.)
  5. PHP is an open source software
  6. PHP is free to download and use
  7. PHP files can contain text, HTML tags and scripts
  8. PHP files are returned to the browser as plain HTML 
  9. PHP files have a file extension of “.php”, “.php3”, or “.phtml”
  10. PHP programs start with “” tag. e.g:
  11. HTML can be written inside a PHP code block just like JSP and Servlets in Java
  12. PHP runs on different platforms (Windows, Linux, Unix, etc.)
  13. PHP is compatible with almost all servers e.g. apache, IIS, etc.
  14. PHP official website is: www.php.net
  15. PHP is easy to learn and runs efficiently on the server side

How to start with PHP?
1. Download and Install WAMP SERVER. Click here to download.
2. Create and store your php files in the www directory of installed wamp server which can be generally found in c:// drive or in the drive where you have installed the wamp server.
3. Start the wamp server
4. Click on the tray icon of wamp server and after the pop up menu appears click on the localhost option.Example Program 1:

To RUN:
1. save this file as index.php
2. put the file index.php in a folder name first
3. now move the folder to www directory of wamp server
4. start the wamp server
5. click on the tray icon of wamp server
6. click on localhost from the pop appeared
7. click on the folder “first” listed under heading “your projects”
8. You can see the output now.
Output of index.php : Hello World in PHP!Hello World!
Note:
echo is used for printing or displaying data in php we can use ‘Hello World!’ (single quotes) or “Hello World” (double quotes).

Example2 : variable.php

";
echo $variable2;
echo "
"; echo $variable3; echo '
'; echo $variable4; ?>

Note:
Perform the same steps as above to run.
Output:

90
String
c
98.05

In PHP there are no primitives like in java. Every variable starts with $ sign and can hold any type of value the PHP handles it implicitly to find out the type of value the variable is holding and by default it is considered as a string.