PHP Introduction

PHP is the most know language available on website, and the most used by the webmasters.
What is PHP?
Php is a "server-side language", what this means ? This mean that, unlike Javascript and html, the php script is executed on the server side, the client ( website visitor) will not get any php script and will not do any modification to the html page, just the server will add some modifications to the html page and will send it to the client, and the client will receive a simple html page.
PHP in example.
Let's say for example; in some website, when you login, you found your name in the page, when you check the source code of the page, you will see something like that: ( if you understand the html)

<html>
<head>
<title>member login</title>
</head>
<body>
Hello Jack
</body>
</html>


Ok, how you name is in the html page ?! The browser just downloads the page and shows it, how your name is in ?
Is every body who opens this page will get my name ? the answer is no, every visitor get a different name, this means different page !
You say different page ? In the same URL ? !
Yes this is it, this is the power of the php ! Every visitors get a different/custom file from the server, the server choose what to write to the html page, and with this php will be like that:

<html>
<head>
<title>member login</title>
</head>
<body>
<?php
echo "Hello " . $myname;
?>
</body>
</html>


$myname is a php variable, and the echo is a function that tell php to write directly to the file, so in this script, we ask php to write the name of the person ( which is saved to this variable when he logged in) to the html page, this is easy with php, don't think ? And it become just like that:

<html>
<head>
<title>member login</title>
</head>
<body>
Hello Jack
</body>
</html>
Thank you friends !
Next post: PHP Syntax.

0 comments: