Friday, 8 March 2013
Write PHP Source Code In Text Editors And Run In Browsers
Writing PHP Source Code :
PHP Source Code |
After installing and configuring Xampp and installing PHP editors. Now its time to write first php program source code. There are two ways to write php source code.
- By Using PHP Designer (For Advanced Users)
- By Using Text Editors Like Notepad++ (For Basic Users)
First Of all install and customize XAMPP and run servers. For checking that Xampp has been properly configured and servers are running properly, goto http://localhost/ or http://127.0.0.1/. For writing php program in PHP designer open a new file of PHP. If you are using notepad++ then simple write the code in a text file and save it in c:\xampp\htdocs
PHP File |
Now we will write our program. You can write this program in notepad or any text editor like PHP designer. To view the output just open the file in web browser.
notepad++ new file |
Save file |
RUN COde IN WEB BROWSER |
<html>
<head>
<title> My First PHP Script </title>
</head>
<body>
<?php
// This Script Will Print New Line
echo " Hello World ! This is my first PHP Script ";
?>
</body>
</html>
After writing this code save your file
c:\xampp\htdocs named as "firstprogram.php"
To see the output go to php designer and click on Localhost or if you are using notepad++ then write the address (http://localhost/firstprogram.php) in any of the browser and then press enter to see the result in browser.
PHP Program OUTPUT in PHP Designer |
When we embed php script in html then first of all we open the php tag
<?php and then we write the php script like echo"this is my first php script"; and at the end close the PHP tag ?>
<?php and then we write the php script like echo"this is my first php script"; and at the end close the PHP tag ?>
Source Code |
<?php
echo"this is my first php script";
?>
By using statement of echo , any variable, text written in single quotes or double quotes can be printed on web page.In place of echo you can also use the statement of print. You can also use print statement instead of echo statement, it will also print on the web page. If we put HTML tag within quotes in echo statement then they will be rendered as follows :
echo "<b> Welcome To PHP </b>";
The output of the above statement will be :
Welcome To PHP
I recommend all learners to use notepad++ to write php programs and the viewing it by http://localhost/filename.php in browser. The output will be displayed in the browser window. You have to write the filename.php at the end of localhost.
Over To You :
I tried my best to explain this tutorial. If you have still any problem then feel free to ask in comments. I will be happy to answer them all. Also share this post with others so others may also get help if they are searching for this topic. Subscribe to get future posts. Stay Blessed. Thanks
Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →
Related Posts:
PHP Tricks and Tutorials Web Development
Subscribe to:
Post Comments (Atom)
0 comments: