KrownMS
Please log in or you cant post!
Remember to Vote!!
KrownMS
Please log in or you cant post!
Remember to Vote!!
KrownMS
Would you like to react to this message? Create an account in a few clicks or log in to continue.

KrownMS

v.83 EXP: 850x Meso: 200x Drop: 3x Remember to vote and donate!
 
Vote!  HomeHome  PortalPortal  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

 

 [Easy] PHP Operators

Go down 
AuthorMessage
Jamie

Jamie


Posts : 7
Join date : 2011-10-24
Age : 29
Location : London, England

[Easy] PHP Operators Empty
PostSubject: [Easy] PHP Operators   [Easy] PHP Operators EmptyMon Oct 31, 2011 8:41 am

PHP Operators are small functions that will come in very useful during coding and generally involve maths an example is x=x+1, this will make x (an integer hopefully) increment once, if it is set as nothing it will give an error, if it set as any other data type it will give an error.

Some examples of arithmetic operators are;

CODE | OUTCOME

x=x+2 x has 2 added to it
x=x-2 x has 2 taken from it
x=x*5 x is times'd by 5
x=x/5 x is divided by 5
x++ x is incremented (+1)
x-- x is decremented (-1)

-------------------------------------------------------------------------

Assignment operators are used for assigning a value to a variable, there are many of them to be used.

Some assignment operators are;

CODE | OUTCOME

x=y x becomes the same value as y
x+=y x becomes the value of x+y
x-+y x becomes the value of x-y
x*=y x becomes the value of x*y
x/=y x becomes the value of x/y
x=y+7 x becomes the value of y+7
x=y-7 x becomes the value of y-7
x=y/7 x becomes the value of y/7
x=y*7 x becomes the value of y*7

------------------------------------------------------------------------

Comparison operators are generally used in if statements as a condition and are useful to set conditions.

Some examples of comparison operators are;

CODE | OUTCOME

x==1 (if) x equals 1
x!=1 (if) x is NOT equal to 1
x<>1 (if) x is NOT equal to 1
x>1 (if) x is greater than 1
x<1 (if) x is less than 1
x>= (if) x is greater than or equal to 1
x<= (if) x is less than or equal to 1

similar are logical operators, also used in IF statements or similar, they are;

CODE | OUTCOME

&& AND
|| OR
! NOT

i.e

IF (x==8 && y==7) {};
IF (x==8 || y==7) {};
IF (x!=8 ) {};
Back to top Go down
 
[Easy] PHP Operators
Back to top 
Page 1 of 1
 Similar topics
-
» [Easy] PHP Basics
» [Easy] Getting ready for PHP

Permissions in this forum:You cannot reply to topics in this forum
KrownMS :: KrownMS :: Guides & Tutorials :: Coding, HTML/PHP Tutorials-
Jump to: