Today We are going to see some basics of PHP. What is PHP & we write our first PHP program.
PHP is a server side scripting language. that is used to develop websites or Web applications. PHP stands for Hypertext Pre-processor, that earlier called as Personal Home Pages.
This definition is just definition, That just for you to as like we have habit to have definition of terms. But knowing definition not means you know PHP.
So let’s dive into deep in the ocean of PHP.
Some Points You Must remember.
1) PHP file have *.php extension other extensions are also there that supports php code are
but now everywhere *.php is used.
2) You need some server that Parse the PHP in to hypertext(HTML) and send it to Browser , as we already seen in lecture 1, the Browser only knows HTML,CSS,JS languages . So do you want the proof , just try to open *.php file in browser without using any server, just like as if you open image in browser. What you will see the code as it is..!
But this code is not executed. So what we need that make our life simple..? Yeah it’s server we need. Here we use Apache Server that do the parsing task.
3) In order for the this server to identify the PHP code from the HTML code, we must always enclose the PHP code in PHP tags.
<?php …. ?>
<?php is opening tag.
?> is closing tag. The php code statements are written between these opening & closing tag.
4) PHP is a case sensitive language, “ABC” is not the same as “abc”. But
<?php is not case sensitive you can still write opening tag as <?PHP but it is strongly recommended that you use <?php
PHP statements closed with a semi colon (;). If you only have one statement, you can skip the semi colon. If you have more than one statement, then you must end each statement with a semi colon. PHP scripts are executed on server that renders it in form of HTML.
4) If you are interested in running php code on your local machine you need XAMPP. You can download XAMPP from https://www.apachefriends.org/download.html
This is our first simple program which shows us Hello world..! text on browser.
<?php
echo "Hello world..!";
?>
Output:
Hello world..!