Learn PHP How to Make a Simple web site Page

In case of a HTML page, at the time of loading, all html elements will load to client’s (user) computer, and then user’s browser will convert all loaded html tag to original page. Here HTML page depend client’s browser like Mozilla Firefox. That is HTML (Hyper Text Markup Language) is a client level language.

But in case of PHP (PHP Hypertext Preprocessor), all codes will execute in hosted server, and then only result page will load to client computer. That is PHP is a server side scripting language.

Here, let’s discuss how to make a simple PHP page with your name. PHP pages will load only from a server, so we need a server. It is difficult to get a server for study purpose. So as a student, we are using WampServer software for taking our computer as a virtual server.
Ø Download WampServer from here.
Ø Then install and open it.
Ø Now you can see WampServer icon in your notification area (right bottom of desktop). Click it. From given small menu, click on ‘www directory’ or go to ‘C: \wamp\www’ (according to your installed location).

Learn PHP How to Make a Simple web site Page

Ø From given directory window (www), make a new folder (eg: Test). Open it, and then make a new text document (right click -> New -> Text Document).
Ø Now open your text document.
Ø Now you have to type PHP codes here. Syntax of a PHP code is like below:

<?php

[Your php codes]

?>

You can type HTML tags in a PHP files, like:

<html>
<body bgcolor = "red">
<?php

[your codes]

?>
</body>
</html>

Here HTML part will control by HTML parser, and PHP parts will control by PHP parser at the time of execution.
In PHP, key word ‘echo’ is using for printing texts.
Ø Let’s make a PHP file with your name:

<html>
<body bgcolor = "aqua">
<?php
echo "You Name";
?>
</body>
</html>

Ø Save this file with name ‘index.php’ using 'Save As' [File -> Save As].

Learn PHP How to Make a Simple web site Page

Ø Now let’s see your first PHP page with name. For this, click again on WampServer icon from notification area. From given menu, click on ‘Localhost’.
Ø Now you will get your local host page in your browser. If you face any errors at the opening local host, then solve here.
Ø In local host page, under the heading of ‘Your Projects’ you can see you folder name made in ‘www directory’ (eg: Test).


Ø Click on that folder name. Now you can see output of your first PHP page like this:

Learn PHP How to Make a Simple web site Page





No comments:

Post a Comment