iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 12, 2008
Film Makers, Bands and Comedians Welcome on MySpace
About
 
May 12, 2008
Software Engineering for Ajax
WebReference.com
 
May 12, 2008
What is the Head Tag For?
About
 
May 11, 2008
Improving accessibility for motor impaired users
WebDevTips UK
 
May 11, 2008
10 ways to orientate users on your site
WebDevTips UK
 
May 11, 2008
Web Design Clinic - Rros restoration camp 2006
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP /Introduction to PHP

PHP Lesson Two - Variables 

  Views:    25009
  Votes:    4
by James N Hitz 1/23/04 Rating: 

Synopsis:

Lesson 2: takes you into the realm of PHP variables, how they are defined, concatenation and PHP operators.
Pages: firstback1 2 3 4 5 7 8 9 10 forwardlast
The Article

Their application should be obvious Common PHP Operators

There are so many PHP operators. A more thorough version with more detailed explanations is given here. Below we have extracted the list of the most common.

 =  Assign  Used for assigning values to a variable
 +=  Add and Asign  Adds a value to an exisisting variable and assigns the answer to the same variable
  -=  Subtract and Assign  Subtracts a value from an exisiting variable and assigns the answer to the same variable
 *=  Multiply and Assign   Multiples an exisiting variable's value by another value and assigns the answer to the same variable
 /=  Divide and Assign   Divides an existing variable by a value and assigns the answer to the same variable


Pause

I know the above operators (save for the first one) may be making your head spin. Rest easy. I'll explain one of them after which the others will be a breeze.

Supposing we have a variable $price which we assign the value 20:

$price = 20;

If we wanted to add a 5.00 storage charge to the price we would say that the new $price is the previous $price plus 5:

$price = $price + 5;

This can be "short-circuited" to read thus:

$price += 5;

This means the same as -=, /= and *= but with subtraction, division and multiplication respectively.

Have we cleared the air now? Hope so. Now, Play (remember the Pause?)

 ||   Or   Tests if EITHER one of the operands evaluate to TRUE
 && And  Tests if BOTH of the operands evaluate to TRUE 
 ^  Exponent  Raises to the power of eg 10^2 (10 to the power 2) 
 ==  Equality  Tests whether the operands are equal
 !=   Non-Equality  Tests if the operands are NOT equal
 < <= > >=  less than or equal to, Greater Than and Greater than or Equal to respectively.  Their application should be obvious
 *   Multiply  Their application should be obvious
 /  Divide  Their application should be obvious
 %  Modulus  Returns the remainder (modulus) eg 10%3 = 1

If you want to have a better look at operators, click here. Otherwise, I will assume you are okey and that things are fine. Come on {Shhh}no one will know you clicked{/Shhh}. Now... Back to Variables.

Pages: firstback1 2 3 4 5 7 8 9 10 forwardlast

Similar/related articles:


 
  Sponsors