Jump to content
xisto Community
HannahI

Learning Php - Part 2

Recommended Posts

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

Edited by HannahI (see edit history)

Share this post


Link to post
Share on other sites

Chapter 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 */.

From a formal point of view, I would like to add two comments.

First of all, usually, a chapter is a set of several pages in a book.

A two-lines text should not be named "chapter".

 

Secondly, be kind with your public.

If you just started here, please go back and read myy other tutorial.

It would be nice to add a link to go to the "other" tutorial you are talking about. Because, hopefully, you will write down several "other" tutorials, so a newbie cannot guess which one you are talking about.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • 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.