PDA

View Full Version : PHP: Getting started Part.1


Fenty
06-24-2006, 06:22 AM
Getting you started
To start working with php you need to tell the webserver (ie. Apache) that your starting to use PHP code. So to do this you start the php tags.

<?php
//PHP Code inbetween the tags
?>
OR alternatively you could use

<?
//PHP Code inbetween the tags
?>


Make a new document called firstscript.php and type the following:

<?php

//Print Output
echo "Hello World!";

?>


yes yes its the cheesy over-rated traditional program. Anyway load the page to see what it displays.........Im presuming you knew what was coming and you most probably guessed right, and it just say's:

Hello World!

on your browser's window. Well thats the echo function and it basically displays any information you ask it to display on to the browser.


Now look at the source of the page.

Internet Explorer: View > Source
Firefox: View > Page Source

You will notice that there is no <?php ?> tags found in the source at all! Why's this? Because Apache Recognised your request for php and sent it to be parased by PHP. PHP exicuted the request between the <?php ?> tags and changed it with the output code from php which in this case was Valid HTML meaning the browser could take and display the content.

It is also possible to comment on your scripts like I have done so in the above example. PHP Supports single line comments as well as multi-line comments too! So thats all good for big paragraphs of comments heh.

So an example of these comments are:

<?php

//A single lined comment

/* And this is
a Multi-lined
comment*/

?>
A quick note to remember, you can leave as many blank lines as you wish because the PHP paraser ignores these.

Copyright Notice:
This article is copyright, The-Wragg 2006. All Rights reserved
Source Code within this article is provided with no warranty or support.
The source code supplied is for illustrative purposes only.
Copyright Infringement is a violation of the law.

PhaNtoM_PHoenIX
06-24-2006, 06:41 AM
Nice tutorial.

sick_side
06-24-2006, 07:06 AM
kooooool
need ta learn this shit

dkb19
06-24-2006, 07:13 AM
good work fenty

random
06-24-2006, 02:18 PM
wicked, i'm learnin php while making my online store :)

Fenty
06-24-2006, 02:35 PM
heh, if your making your own online store make sure its 100% secure and runs against creditcard fraud checks as well as using a payment method ie paypal creditcard

random
06-24-2006, 02:42 PM
heh, if your making your own online store make sure its 100% secure and runs against creditcard fraud checks as well as using a payment method ie paypal creditcard
yee i've got paypal setup, and gonna put barclays ePDQ service as well :) get ready to buy lots of stuff from me lol

Fenty
06-24-2006, 02:52 PM
whatcha selling?

kartel
07-06-2006, 03:25 PM
i think i need to get on this myself now...thnxs!!!