Results 1 to 4 of 4
  1. #1
    yearupie's Avatar
    Join Date
    Apr 2008
    Gender
    male
    Posts
    54
    Reputation
    11
    Thanks
    2

    PHP Beginners Guide #1

    Best Forumer,

    I would like you to explain how php works, many people think they know something about PHP, but it is often not correct. Let's start with the basics!

    Chapter 1: Variables

    § 1: Introduction
    Variables can be used to temporarily store data. Such information may consist of numbers (integers) or pieces of text (strings), but can also be true / false data (booleans) or a set of data (array) contain. All we can create in PHP, we can put in a variable.

    § 2: Creating variables
    Creating a variable, also called declaration, done by one U.S. dollars sign ($) followed by a random name. With the equal-to (=) sign, we can then assign a value to the variable. Finally, we close the line with a semicolon.

    [php]<?php
    $text = 'Hello World!';
    echo $text;
    ?>[/php]

    This piece of code we declare the variable $text, adding the value "Hello World!" to it. Then we use an echo to the contents of $text to put on screen. The output is as follows:

    Hello World!
    § 3: different types of variables

    As I mentioned earlier, we can actually save everything in a PHP variable. Depending on the content of a variable belongs to a particular type. Some examples:

    [php]<?php
    $text = 'Hello World!'; // String
    $age = 28; // Integer
    $price = 190.75; // Float
    $check = false; // Boolean
    ?>[/php]

    Here are some examples of different types of variables. The first variable $text we have already seen and contains a string. If you store numbers in one variable, it is an integer, a float if you concern about the numbers have decimal. If a variable includes true or false, you call it a boolean. A type variable that is not in this example is the array. On this variable I will make a separate tutorial.

    As we will see a string in PHP is placed between single quotes. In an integer, float or boolean we do not use quotes!

    § 4: Calculating with variables
    We have already seen that we can echo variables, but that's not all. Calculating with variables in PHP is something that we will use frequently. Some examples:

    [php]<?php
    $amout = 10;
    $price = 9.95;
    $btw = 0.19; // 19%

    $subtotal = $amout * $price; // Calculate subtotal
    echo 'Subtotal: '.$subtotal.'<br />';

    $aBtw = $subtotal * 0.19; // aBtw = After BTW Calculate BTW
    $total = $subtotal + $aBtw; // Calculate Total
    echo 'Total: '.$total;
    ?>[/php]

    Output:
    Subtotal: 99.5
    Total: 118.405
    This was Chapter 1, soon I will go to the next chapter.
    Last edited by yearupie; 03-08-2010 at 11:57 AM.
    This forum is great!

  2. The Following 2 Users Say Thank You to yearupie For This Useful Post:

    Spookerzz (03-08-2010),twox (03-23-2010)

  3. #2
    Spookerzz's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    4,647
    Reputation
    26
    Thanks
    572
    Is this from W3 Schools?

    Oh well nice tut

    Thanked and repped
    I'm back.

  4. #3
    yearupie's Avatar
    Join Date
    Apr 2008
    Gender
    male
    Posts
    54
    Reputation
    11
    Thanks
    2
    Quote Originally Posted by ___GodLike___ View Post
    Is this from W3 Schools?

    Oh well nice tut

    Thanked and repped
    Uhuh I don't leech!
    >>95% from Yearupie <<
    This forum is great!

  5. #4
    Spookerzz's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    4,647
    Reputation
    26
    Thanks
    572
    Ok nice one but don't annoy nextgen
    I'm back.

Similar Threads

  1. [Tutorial] D.N.A's Beginner guide to Minecraft Modding
    By D.N.A in forum Minecraft Tutorials
    Replies: 1
    Last Post: 06-05-2011, 02:41 PM
  2. Beginner Concepts of Game Hacking
    By why06 in forum Programming Tutorials
    Replies: 59
    Last Post: 04-27-2010, 12:47 AM
  3. The Ultimate Guide(For Beginners): Reversing
    By rwkeith in forum Assembly
    Replies: 2
    Last Post: 07-27-2009, 11:02 AM
  4. Replies: 1
    Last Post: 06-06-2009, 02:50 AM
  5. Beginner Guide to using T-Search
    By arunforce in forum Game Hacking Tutorials
    Replies: 0
    Last Post: 01-02-2006, 08:13 PM