Thursday 16 May 2013

Lesson -1 PHP Introduction and Hello Application


PHP Introduction and Hello Program

PHP was introduced in 1995. The full form of PHP at that time was Personal Home Page. But now it is known as Preprocessor Hypertext. PHP is an Open Source. It is server side Scripting language which is embedded with HTML. PHP is generally used to develop dynamically web based application.  PHP is very fast and easy to learn. It support almost all database like MySql(which is mostly used with PHP), oracle, MS SQL Server etc.

Compilation of PHP
Phalanger is a compiler which compiles the PHP code into Common Intermediate Language bytecode and then this code executed by PHP Engine.

PHP Server installation

As I already told that php is a server side scripting language so we need server to run php code. There are many servers to run php program. If you are using Windows Operating System then you can install Wamp server which stands for Windows Apache MySql and PHP or Perl or python.  It is a complete package. And if you are using Linux Operating System then you can install Lamp which stands for Linux Apache MySql and PHP or Perl or python.

Here I am using Wamp server. When you installed wamp server you will get wamp folder in your C drive. In this folder there is another folder name www. To run php code we have to put all php files in this folder. Php files having .php extension. We can use Notpad or Notepad++ to create php files.

Hello Application using PHP

Following are the steps to develop your first php page:-
1.     Open the Notepad or Notepad++.
2.     Every php code written between the following code:-
<?Php
  
Php code…………

?>
3.     To print on the screen we use echo command.

Following is the complete code to print hello

<?php

echo 'hello Isha Malhotra';

?>

With echo you can use both single quotation and double quotation.

To execute this code save it with .php extention and save it in the

C:\Wamp\www\hello.php

After that start the Wamp server then open any browser and type following code:-

http://localhost:8080/hello.php

Note:-8080 is port number. As I am using two Servers(IIS and Wamp) so that I have to change its port number. But if you are using only Wamp server then it will be 80. But if you have skype in your computer then you also have to change your port number by replacing the 80 to 8080 in httpd.conf file. Following is the way to open this file:-


Figure 1
Now Edit this file by replacing 80 with 8080.
Now run the php hello code and you will get the following output:-




Figure 2

For those who knows Java Script:-

If you know javascript then you also know how we write javascript in html. As we know that php is a scripting language and embedded with HTML. So we can perform this task in following manner too:-

<html>
<head>
<script language="php">
echo 'hello Isha Malhotra';
</script>
</head>
</html>
In this article I described the basic part of php. For any problem and query you can write me mail at info@techaltum.com





No comments:

Post a Comment