iWebBuddy.com - Website Design and Web Development Forum
Thanks for visiting iWebBuddy.com ,

If it is your first time here, please enjoy reading the tutorials and articles. If you can not find what you're looking for, then you can join the forums by registering so you will be able to log into the forums and ask for support for website development, request graphic designing services, promote your website, request website reviews, get advice from others about your website or be an active member of the community to help iWebBuddy.com grow.

After you register an account, you are required to log in. Once you log into your account, you will have more privileges. You will be able to post on the forums, send private messages and view the Chatbox ( link ) at the bottom of the forums.

Have a nice day.

"Hello World" in PHP

Post new topic   Reply to topic

View previous topic View next topic Go down

"Hello World" in PHP

Post by dsignresponder on Tue Dec 15, 2009 9:02 am

The very first program in any book, tutorial or lesson, regardless of the scripting language is usually the "Hello World" program! Smile

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!
Very Happy

It was really simple wasn't it? greatwork

Let me know if you're having problems!

dsignresponder
Forum Newbie
Forum Newbie

Posts Posts: 9
iCoins iCoins: 30

View user profile

Back to top Go down

Re: "Hello World" in PHP

Post by Rehua on Thu May 06, 2010 12:16 pm

Oh god, this looks way harder than HTML. XD

Rehua
WebBuddy
WebBuddy

Posts Posts: 24
iCoins iCoins: 82

View user profile

Back to top Go down

Re: "Hello World" in PHP

Post by hypokill on Thu May 06, 2010 5:26 pm

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
Moderator

Posts Posts: 124
iCoins iCoins: 426

View user profile http://rozzex.com

Back to top Go down

Re: "Hello World" in PHP

Post by Rehua on Sat May 08, 2010 3:55 pm

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 Razz.

Rehua
WebBuddy
WebBuddy

Posts Posts: 24
iCoins iCoins: 82

View user profile

Back to top Go down

Re: "Hello World" in PHP

Post by hypokill on Sat May 08, 2010 6:29 pm

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 thumbsup2

hypokill
Moderator
Moderator

Posts Posts: 124
iCoins iCoins: 426

View user profile http://rozzex.com

Back to top Go down

Re: "Hello World" in PHP

Post by Charlie on Sat May 15, 2010 11:26 pm

Mmm Smile

Charlie
Active WebBuddy
Active WebBuddy

Posts Posts: 56
iCoins iCoins: 190

View user profile

Back to top Go down

Re: "Hello World" in PHP

Post by whatif on Sun May 23, 2010 8:12 pm

And i thought HTML was hard Razz

whatif
iWebBuddy Novice
iWebBuddy Novice

Posts Posts: 108
iCoins iCoins: 139

View user profile

Back to top Go down

View previous topic View next topic Back to top


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