Monday, June 29, 2015

First Page Using PHP

Today We will see that how to write first PHP enabled Program and test that on Browser !
  • Basic Thing Before write a program in PHP.


  1. You required a Server like Apache or any other with PHP configuration.  
  2. You Should Create the PHP file in "DOCUMENT_ROOT"  for XAMPP (htdocs), for WAMP(WWW ), for IIS(WWW) and so for. Directory as PHP.ini are configured.
  3. Start to write a PHP Script
                File name: Hello.php 


  <html>  <head> <title> My First PHP Program! </title> </head><body><?php
                    /*PHP Script Start Here.*/ 
echo "Welcome to PHP!"; /* This statement print the Message Welcome to PHP! */?></body><html>
Then open start the service and then Open http://127.0.0.1/Hello.php or http://localhost/Hello.php 

Output will Display like this..
Code in Editor.


Output on Browser.

In output in Browser Picture 1: Title of the Page
                                               2: Address in which your php is save (DOCUMENT_ROOT/blogs)
                                                3:Output of PHP Script!
If you try to see the source of the page in Browser the PHP Script look like test.

View Source Window in Opera.
              Highlighted Part the Main PHP Script <?php echo "Welcome to PHP!" ?>
             After Process by Apache Server the Script become "Welcome to PHP!".


  •          If output is display like below code that means your PHP Configuration in not Set     Correctly to do that and restart the server and then try. 



 <html>
 <head>
 <title>PHP Test</title>
 </head>
 <body>
 <p>Hello World</p>
 </body>
 </html>
Have a Good day and Happy Programming..

No comments :

Post a Comment