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