UK Webmaster Talk - Online Marketing - SEO


 

Basics of PHP

This is a discussion on Basics of PHP within the Programming Articles forums, part of the Webmaster Articles/Tutorials category; This tutorial is for first time PHP users and will teach you the basics of creating a simple PHP page ...


Go Back   UK Webmaster Talk - Online Marketing - SEO > Webmaster Articles > Webmaster Articles/Tutorials > Programming Articles

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices

Reply

 

LinkBack Thread Tools Display Modes
Old 07-04-2005, 16:12   #1 (permalink)
Bmg
WMT Addict
 
Join Date: Apr 2005
Posts: 227
iTrader: 0 / 0%
Bmg is on a distinguished road
Default Basics of PHP

This tutorial is for first time PHP users and will teach you the basics of creating a simple PHP page that assigns values to variables and then displays them onto the browser.

First off, load up a text editor such as notepad.
All PHP coding must be surrounded by the php opening and closing tags which are:

<?php CODE HERE ?>

And any page you save that contains php must be saved with the extension of .php E.G. "index.php" "content.php".

They are the basics of starting and closing php pages and saving them, now for the basic coding.
All php variables beging with a dollar sign($). There are some rules with using variables though.
1)Start with a dollar sign
2)You must follow the dollar sign with an underscore(_) or a letter, this letter can however be uppercase or lowercase.
3)You can have as many characters as you like but don't go over the top, in some scripts you create you might be having to typing it numerous times so this could get tedious with long variable names.

Here are some examples of VALID variables:

$width
$result
$_result
$_x


So now we know the rules on making variables below is how you assign a value.
Assigning values to a variable is very simple all you do is:
$result = 'the variables contents here';
Every line of PHP code has to end with a semi-colon! Otherwise it will produce errors in the PHP Syntax. Below are examples of setting variables with values:

$result = '123';
$_x = 'I like PHP';
$RESULT = 'This is different to the variable named result';


Now to learn how to display the variables (and normal text).

To display text on the screen you need to use the echo function. To use this simply imbetween the opening and closing tags

echo "YOUR TEXT HERE";

REMEMBER THE SEMI-COLON AT THE END OF THE LINE!
Although displaying variables is different. Below are examples of different ways to displaying variables:

echo "SOME TEXT HERE". $variable ."SOME MORE TEXT HERE";
echo $variable ."TEXT HERE";
echo "TEXT HERE". $variable;
echo $variable;



Now you just upload all of this to a PHP webserver and you are done. Have questions? PM me or post it here on the forums.
Bmg is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
basics, php

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
User System Basics mck9235 Programming / Scripting / Coding 3 15-04-2005 20:31
Website Accessibility - The Basics Wistow Website Design Articles 0 19-03-2005 15:52


All times are GMT +1. The time now is 16:35.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
UK Webmaster Forum © WebmasterTalk.co.uk | Design by Forbairt

Ad Management by RedTyger

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41