[CashFX] PHP Tutorial #1 - The Basics 04-15-2013, 09:52 PM
#1
![[Image: Tl3xIiy.png]](http://i.imgur.com/Tl3xIiy.png)
HOSTED BY CASHFX
Tutorial #1 - PHP Basics
So, my first tutorial! Woo! I thought I'd give something back! YAY! This is the way I learned PHP, and I'm stupid. So hopefully, you'll be able to understand it!

Anyway, I hate huge intro's, let's just get stuck in

This tutorial does assume that you know basic HTML. I will probably post tutorials on that at a later date, but no promises.
PHP uses a syntax similar to objective C and Perl, however it does look more like Java.
Semicolons
PHP Code:
$i += 15;
Why are they used? Well, the server would have to try to differentiate the end of one command and the start of another, whereas with semicolons, you tell it. It speeds up the formatting of the page the server will send out (parsing).
The '$' Sign
The $ sign is used across many programming languages, some for different purposes, but is usually quite fundamental. A '$' should be placed in front of a variable. Why? Because, again, it makes the PHP parse faster.
An example of this would be:
PHP Code:
<?php
$stringhere = "This is some text";
echo $stringhere;
?>
Types of variable
So, there are three main types of variables in PHP:
- String
- Integer
- Array
What is a string? Well, a string is a set of characters that are text, such as 'Hello, I'm McDork'. When defining a string, the text should always be enclosed in speech marks:
PHP Code:
$hello = "This is my string";
What is an integer? An integer is a number. These don't need to be enclosed in speech marks:
PHP Code:
$mynumber = 123;
What is an array? Well, let's say you have 5 things you want to store, such as names in the variable $names. You would have to create an array:
PHP Code:
$names = array('Joe', 'Jack', 'James', 'Windox', 'Peter');
PHP Code:
echo $names[0];
PHP Code:
echo $names[2];
PHP Code:
echo $names[4];
*REMEMBER* Indexing for arrays start at 0! (Thanks VipVince - my mistake!)
Arithmetic operators.
Now, you will be thinking, I'm not gonna do any math! Oh yeah you are. When handling data, you will always find a situation where you will need to be using some mathematical operator.
Here they are:
- + Addition
- - Subtraction
- * Multiplication
- / Division
- % Modulus (division remainder)
- ++ Increment
- -- Decrement
If you don't know what any of those words mean, use google. I'm not here to teach maths

There are other types of operator such as Assignment or Comparison operators, however, we will get onto those in later tutorials.
Anyway, if I've bored you enough, I can assure you, that that's it will get better, and you will be able to come up with a functioning website that does quite complex things by the end of this tutorial series.
-Mr. Donuts
![[Image: fwFzNUP.png]](http://i.imgur.com/fwFzNUP.png)