tags: apache   archive   business   charity   climbing   comic   communication   database   email   exchange   family   fm2008   hack   hardware   humour   linux   liverpool   microsoft   money   mysql   network   oes   opensource   outlook   php   pictures   process   project   quote   real_life   review   rss   science   security   software   thought   tsm   updates   webdev   website   windows  

Basics of PHP - Part 2

Thu, 23 Aug 2007 07:46:55
Basics of PHP - Part 2

Today we'll start by storing a variable. A variable is like an alias, a friendly name for a particular string you've predefined. Don't worry about new lines when writing your script, php ignores them.

<?php
$var1 = "hello world, ";
$var2 = "how are we today?";
?>

Let's take a look at the code line for line;
<?php - Open PHP tag
$var1 = "hello world, "; - Define $var1 and end with ';' to tell PHP we've finished with that line of code
$var2 = "how are we today?"; - Same
?> - Close PHP tag

Now that we have out variables defined, let's echo them out

<?php
echo $var1 . $var2;
?>

This would display "hello world, how are we today?" on our webpage. The full stop between the varialbes acts as an 'and'. We begin by using the echo function and ask it to echo out $var1 AND $var2.

Stay tuned
Ryan Partington