PHP - Simple Sampe Hello World Script Example

RegisterLogin
PHP - Simple Sampe Hello World Script Example
Post Description: PHP - Simple Sampe Hello World Script Example
Tags: PHP, -, Simple, Sampe, Hello, World, Script, Example
This Post Was Posted On Feb 29, 2008 By stalionboy #469
In this tutorial I will show you how to start writing your first PHP script.

First, its important that you have php. If you don't have php, we recommend you buy a php plan from our friends at www.webune.com they have great PHP hosting plans for your domain name or website.

Ok, that's all you need - PHP hosting. Once you know you have php, you can continue, otherwise, if you don't, this script will not work unless the script is parsed by PHP engine.

Step 1: Open your your favorite text editor. I will be using Microsoft Window's Notepad in my examples. But you can use any ascii text editor. Don't use text editors like Wordpad or Word.
post picture

Step 2: Copy and paste the following code into the blank text editor:


     Code:
<?php
# my first php script
echo "Hello World!";
?>

post picture

WHAT DO THESE LINE MEAN:
LINE 1: <?php - This tells your Apache Server that you are starting a PHP script.

LINE 2: # my first phpe script - Whenever a line start with a #, it tells the server to ingore this command because is a comment. Comments are very important when creating scripts.
LINE 3: echo "Hello World!" - The echo tells your server to display Hello World! into your browser.
LINE 4: ?> - You must close your <?PHP tag. Just like HTML tags, you must close all your PHP tags.


Step 3: Save the file as "hello-world.php" (include the quotes if you are using Notepad)

post picture

Step 4: Upload hello-world.php file to your website.

[This post sponsered by www.webune.com]
post picture


Step 5: Open the file with your browser from your website.
SEE DEMO: http://www.webune.com/tutorials/hello-world/hello-world.php

Step 6: Done. You have now created your first PHP script

NEXT: The next tutorial will show you how to integrate the PHP script into and HTML document page.
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
©2012 Webune Forums - Sat Dec 15, 2012 11:40 am
Powered by: Webune Forums V3