Today We will see that how to write first PHP enabled Program and test that on Browser !
File name: Hello.php
- Basic Thing Before write a program in PHP.
- You required a Server like Apache or any other with PHP configuration.
- 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.
- Start to write a PHP Script
/*PHP Script Start Here.*/
<html> <head> <title> My First PHP Program! </title> </head><body><?php
Then open start the service and then Open http://127.0.0.1/Hello.php or http://localhost/Hello.phpecho "Welcome to PHP!"; /* This statement print the Message Welcome to PHP! */?></body><html>
Output will Display like this..
Code in Editor. |
Output on Browser. |
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