"Hello World" in PHP
iWebBuddy.com - Website Design and Web Development Forum :: Web Design and Development :: Scripting Languages :: Web Server
Page 1 of 1 • Share •
"Hello World" in PHP
The very first program in any book, tutorial or lesson, regardless of the scripting language is usually the "Hello World" program!
If you set up your local web server successfully (Setup Apache), now you're ready to write your first PHP script!
This procedure is usually the same in every case you want to run a php script on a server :
1. WRITE THE script
- open a simple text editor (i.e. notepad)
- type in there :
- where :
2. SAVE THE script/UPLOAD
- save in : C:/xampp/htdocs/lesson_1/hello_world.php
NOTE : the file extension has to be .PHP so the web server can read it accordingly!
3. CHECK
- point your browser to :
If everything is OK, you should see:
in your browser!
It was really simple wasn't it?
Let me know if you're having problems!
If you set up your local web server successfully (Setup Apache), now you're ready to write your first PHP script!
This procedure is usually the same in every case you want to run a php script on a server :
1. WRITE THE script
- open a simple text editor (i.e. notepad)
- type in there :
- Code:
<?php
$my_name = "Peter Pan";
echo 'Hello World!<br />';
echo 'My name is : '.$my_name.'!<br />';
?>
- where :
- Code:
<?php --> this set of characters instructs the web server that PHP lines are following, so the interpreter has to 'translate' ALL the content between <?php and ?> lines!
$my_name --> $ is the char for the variables in PHP (we've set it to "Peter Pan")
echo --> the browser will output (print out) everything after that included between ' ' signs (except the variables : their VALUE will be printed, in our case : Peter Pan)
<br /> --> prints new line
NOTE : every line in PHP ends with ; (except in some cases we will discuss later)
2. SAVE THE script/UPLOAD
- save in : C:/xampp/htdocs/lesson_1/hello_world.php
NOTE : the file extension has to be .PHP so the web server can read it accordingly!
3. CHECK
- point your browser to :
- Code:
localhost/lesson_1/hello_world.php
If everything is OK, you should see:
- Code:
Hello World!
My name is : Peter Pan!
in your browser!
It was really simple wasn't it?
Let me know if you're having problems!

dsignresponder- Forum Newbie

Posts: 9
iCoins: 30
Re: "Hello World" in PHP
Oh god, this looks way harder than HTML. XD

Rehua- WebBuddy

Posts: 24
iCoins: 82
Re: "Hello World" in PHP
Ofcoarse PHP will be alot harder to grasp then html, As the two languages are completely different. PHP is an object orientated language and HTML is just a mark up language. This is about as simple as it gets. It also leads to a whole new way of thinking when it comes to creating applications.

hypokill- Moderator

Posts: 124
iCoins: 426

Re: "Hello World" in PHP
Ah, okay, I don't know much about all those languages, I know the basics of HTML & CSS, and I can use them on Forumotion, but that's all
.

Rehua- WebBuddy

Posts: 24
iCoins: 82
Re: "Hello World" in PHP
i suggest perfecting html and CSS first before moving onto this language. As html and CSS are vital in PHP coding. keep pushing forward with html and css 


hypokill- Moderator

Posts: 124
iCoins: 426

Permissions of this forum:
You cannot reply to topics in this forum















