Jobs New Media Creative Forum Forum Index Jobs New Media Creative Forum
Topics ranging across the Creatives Art & Design and New Media Sectors
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Say it with strings - PHP

 
Post new topic   Reply to topic    Jobs New Media Creative Forum Forum Index -> Web Design
Author Message
jamesmiddz
Site Admin


Joined: 22 Aug 2007
Posts: 9
Location: UK

PostPosted: Sat Sep 01, 2007 7:50 am    Post subject: Say it with strings - PHP Reply with quote

If you fairly new to webdesign and a little afraid of learning about PHP, then read on. PHP is a great language that allows you to do all sorts of things that you simply can't do with standard HTML. You can do quite a lot with only a small amount of PHP knowledge. Feeling adventurous? Well, let's try a few simple things out:

Firstly, it is worth noting that not all servers are configured to allow for the use of PHP. Still, it's worth a try.

Let's create a test file to try out a few PHP basics:

Prepare file
    Load up your webdesign program (ie. Dreamweaver, Frontpage, etc)
    Create a new page and save it as 'test.php' - it must have '.php' at the end in order to work and not '.html'. HTML elements within your created page will function in the same ways as usual.
    You should be able to view your source code - do so.
    Delete any code in the current new page.


PHP start
Within you new page (source mode), type the following, making sure that it is 100% accurate: <?php ?>
Your PHP code will be put between the '<?php' and the '?>'.
Now let's try a bit of code.

Echoing
We are now going to 'echo out' a few word to a browser.

<?php
echo "This is a short sentence"
?>

This will cause the text within the quotation marks to appear at the top left hand corner of our page. In order to see this in action, we will need to copy this file onto our server and load it up into a web browser.

Now, let's try something a little different.

Strings
Strings a basic holder to variable alpha-numeric information.

<?php
$name = "James";
echo "My name is $name"
?>

In the above I have created a string (always designated with a '$'). A string can be call just about anything, but avoid using symbols and spaces.
You may have also noticed the presence of a ';' symbol. This shows that the line has ended. You need to add a ; in order for the script to work.

Ok, that was a short lesson, but if you can get a discussion going, I'll add a lot more.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Jobs New Media Creative Forum Forum Index -> Web Design All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group