Logo Tutorials, Ebooks, Source Codes, Question Bank
Submit your Email ID & receive intimation about New/Updated Contents :
Advertise with us             CONTACT US
Android MobilesHTC MobilesMicromax MobilesMobile ArticlesMobile TermsNokia MobilesSamsung MobilesSony MobilesTablets
108 Names of GodBhajans CHALISA CollectionDevi Maa Ki AartiyanGanesh Ji Ki AartiyanHanuman Ji Ki AartiyanRadha Krishan Ji Ki AartiyanRam Ji Ki AartiyanSai Baba Ji Ki AartiyanShiv Ji Ki AartiyanTemples in IndiaVishnu Ji Ki Aartiyan
Wallpapers Pack
Bollywood FlashsFestival FlashsFlash GamesFlash MessagesFunny FlashsPatriotic FlashsPolitical FlashsSpiritual Flashs
FunStuffJokesRajnikanth JokesWhats App JokesWhats App Messages
About IndiaGeneral Knowledge Hindi RhymesMythological StoriesNursery RhymesPatriotic SongsRiddlesShort StoriesTongue Twisters
Funny SlideshowsInteresting SlideshowsMessage SlideshowsNice SlideshowsPatriotic SlideshowsSpiritual Slideshows
BirthDay SMSChristmas SMSClassic SMSFathers Day SMSFestivals SMSFriendship SMSFunny SMSHoli SMSHusbandWife SMSIndependenceDay SMSLohri SMSLove SMSMorning SMSMothers Day SMSNew Year SMSNight SMSPoetry SMSPunjabi SMSRakhi SMSSanta Banta SmSTeachers Day SMSTimePass SMSValentine Day SMS
3D WallpapersAbstract_WallpapersAnimated_WallpapersApple_Mac_WallpapersBaby_WallpapersBackGroundsBeach WallpapersBirds WallpapersCars WallpapersCartoon_WallpapersChristmas WallpapersColorFul_WallpapersColoringSheetsCool_WallpapersFish_WallpapersFlagsFlash TattoosFlowersFunny WallpapersGalleryGodsGreen_ScenesHD_High_ResolutioniPhone WallPapersLinux_WallpapersMobile_WallpapersMortality WallpapersMountain_WallpapersNatureOptical_IllusionsRosesSea_WallpapersShips WallpapersSports_GamesUltraBeautiful WallpaperValentine WallpapersVehiclesWideScreen WallpapersWildLife WallpapersWindows VistaWindowsXPWindows_7_Wallpapers
AJAX ASP.Net 2.0/3.5 C# / C-Sharp C/C++ Cryptography Data Compression Data Structures FLASH Foxpro/VFP HTML JAVA Java Scripts JSP LINUX Microsoft Office Microsoft Windows MS XNA PHP/MySQL Silverlight Software Engineering SQL SQL Server 2005 UNIX VB.Net 2005 VBScript XML
Home Search

PHP - Working with Operators

Operator is a symbol or can be a series of symbols, which when used with some values performs some action and produce a new value.

Assignment Operator
Assignment operator "=" is most widely used operator in PHP. This operator is used to initialize the variable.This operator is used in between two operands. It evaluates right-hand operand and assigs its value to the left-hand operand. Most operators are used to produce some result without changing the value of their operands. But assignment operator breaks this rule.
print ($name = John); //assigns John to $name, then
outputs $name
At the same time you can perform multiple things. So you can assign not only the word John to the variable $name, but can also output the variable at (almost) the same time..

Dot Operator
Using the concatenation operator we can append additional characters to a string. This is a single dot .. Treating both operands as the string types, it appends the right-hand operand to the left-hand operand, the result is ofcourse, a string.
$first_name = John;
$last_name = Davis;
print $first_name . $last_name; //outputs John Davis

Arithmetic Operators
Arithmetic operators are also used in many programming languages. You know for sure what each of them do, so well just stick to point them out: addition +, subtraction -, division /, multiplication *, and modulus %.

/* define some variables */
$mean = 5;
$mode = 9;

//post-increment operator
//$mean now equals 6

//pre-increment operator
//$mean is now 7

//post-decrement operator
//$mean is down to 6

//pre-decrement operator
//$mean is down to 5

//addition operator
$median = $mean + $mode;
//$median now equals 14

//substraction operator
$median = $mode - $mean;
//$median now equals 4


Comparison Operators
You've already seen some of the arithmetic and string operators in PHP's. However, the language also comes with operators that are designed specifically to compare two values: These operators are called "comparison operators". Here's an example to demonstrates Comparison Operators in action:

/* define some variables */
$mean = 9;
$median = 10;
$mode = 9;

// less-than operator
// returns true if left side is less than right
// returns true here
$result = ($mean < $median);
print "result is $result

// greater-than operator
// returns true if left side is greater than right
// returns false here
$result = ($mean > $median);
print "result is $result

// less-than-or-equal-to operator
// returns true if left side is less than or equal to right
// returns false here
$result = ($median <= $mode);
print "result is $result

// greater-than-or-equal-to operator
// returns true if left side is greater than or equal to right
// returns true here
$result = ($median > = $mode);
print "result is $result

// equality operator
// returns true if left side is equal to right
// returns true here
$result = ($mean == $mode);
print "result is $result

// not-equal-to operator
// returns true if left side is not equal to right
// returns false here
$result = ($mean != $mode);
print "result is $result

// inequality operator
// returns true if left side is not equal to right
// returns false here
$result = ($mean <> $mode);
print "result is $result";


allfree-stuff.com - Free Education for ALL - for any queries contact @ webmaster@allfree-stuff.com