Jump to content
xisto Community

HannahI

Members
  • Content Count

    351
  • Joined

  • Last visited

Posts posted by HannahI


  1. Hi Again,

    If you just started here, please go back and read my other tutorial at http://forums.xisto.com/topic/97338-topic/?findpost=1064404535.

    Today we are going to be learning about the if statement, the else statement, the else if statement, other things.

    Let's Begin. :D

     

    Chapter 2 - If, else, and else if

    The If statement compares 2 variable, a number and a variable, or a number and a number. The else statement is similar to the if statment. The difference between the if statement and the else if statement is that the if statement is in the beginning and the else statement is at the end. I'm guessing that you alraedy guessed that the else if statement goes in the middle, if you did, your correct! :P You can have as many else if statement as you want. On the other hand, if you don't have an else statement, the else if statement could be at the end!

    Example:

    <?php

    $b = 1;

    if($b < 0) {

    echo "Hi";

    } else {

    echo "Hello";

    }

    ?>

     

    Chapter 2 - 2 - Comments

    A comment is a "note to self" which are invisable to the computer. A comment is after //.

    Similar to comment, they're block comment which are multi-line comments. Block comment are /* and */.

    Example

    <?php

    echo 'Hello' // I'm a comment

     

    /*

    I'm a block comment

    blah blah

    Bye

    */

    ?>

     

    Thanks for reading Chapter 2


  2. Hello,

    In this tutorial, I'll be teaching PHP.

    Before we start, let's talk about the basics of PHP.

    You will need a server. If you're on a Mac, Google "Mamp"; if you're on a Linux, Google "Lamp"; if you're on a Windows, Google "Wamp".

    Your files will go in the Mamp, Wamp, or Lamp folder's htdocs.

    PHP stands for Php Hyper-Text Processing.

    PHP is a Server Language, which means that it runs on the server vs. the computer.

    Now let's Begin

    Chapter 1-1 - Beginning

    Every line in PHP ends in a semi-colon.

    99.9% of the time is lower-case.

    Every thing is inside <?php and ?>.

    Chapter 1-2 - Beginning

    A simple, but heplful command is echo which prints HTML on the screen; if you don't understand this, go learn HTML.

    Example:

    <?phpecho "Hello!";?>
    If you do that, you should see the following.

    Preview:

    Hello!

    To create a variable, type $, then the the name (no space), type =, then type a number; if you want it to equal some text, put quotes/single quotes around it.

    To put a variable within a echo statement do it like this.

    Example:

    <?php$hello = "Hello";echo 'Hello is equal to';echo $hello?>
    or

    <?php$hello = "Hello";echo "Hello is equal to';echo $hello;?>
    or

    <?php$hello = "Hello";echo 'Hello is equal to' . $hello . ' ';?>
    Thanks For Reading Chapter 1!

     

    Written by HannahI

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.