Operators In PHP
Operators In PHPThis article is the second of a series of PHP guides that aim at teaching you the basics of PHP programming. Dear pupils, I hope you would have been practising the last lecture ( PHP Programming Basics ) as I am getting feedback from different students from different countries and I am very happy I am able to contribute to PHP through my series of PHP Articles for beginners and professionals. Today we are going to discuss different types of operators used in PHP. I hope you remember the basic definition of the operators and operands from my last article ( PHP Programming Basics ) and I am not going to explain it again as we had promised in the very first article of this Series of PHP Tutorials that we will not see behind and this is just to compell you to concentrate on each and every article of this series and practise (O! I love practice) PHP offers the following operators to perform different operations on the operands. Arithmetic Operators:Arithmetic operators enable you to perform different mathematical operations on different values. Below are the quick details of arithmetic operators, Addition: it is denoted by plus sign ( + ) and is used to add two values e.g 2 + 3 = 5 you can add variables as following, <?php Subtraction: it is denoted by minus sign (  ) and is used to subtract first value from the second e.g 2  1 = 1 you can subtract two variables as following, <?php multipication: it is denoted by Asterisk sign ( * ) and is used to multiply two value e.g 2 * 3 = 6 you can multiply two variables as following, <?php Division: it is denoted by forward slash sign ( / ) and is used to divide first value on the second e.g 2 / 2 = 1 you can divide two variables as following, <?php Modulus(Division Remainder): it is denoted by percentage sign ( % ) and is used to give the division remainder e.g 3 % 2 = 1 you can find the modulus of two variables as following, <?php Increment: it is denoted by doubleplus sign ( ++ ) and is used to increase value of one variable by one e.g <?php Remember there are two types of incrementation, a) Prefix Increment: in which the increment operator comes before the variable name i.e ++$var; In this type of increment the variable’s value is incremented and is available for the immediate use e.g <?php b) Postfix Increment: in which increment operation is performed however the resultant value is not available for the immediate use and can be used only when the control access the variable in the next run e.g <?php Decrement Operator: it is denoted by doubleminus sign ( — ). It is very similar to the increment operator however it decrease the value by one. Assignment Operators: Assignment operators are used to assign new values to a variable. We have the following assignment operator available in PHP, <?php //you can print $var1 after each step to see its value First of all in above all example i am assuming each operation for the basic values of var1 and var2 to be 3 and 5 respectively. Comparison Operators:comparison operators are used to compare two values. We can use following comparison operators in PHP, ( == ) is equal to Just learn these operators by heart we will use them in our up coming articles and you will be able to understand their exact use. Logical Operators:We have three logical operators in PHP, AND ( && ) Operators: you can use both ‘AND’ and doubleempersand sign ( && ) for this operator in PHP. The basic logical use of this operator in a rough psuedocode could be If first condition is true && second condition is also true OR (  ) Operators: you can use both ‘OR’ and doublepipeKey sign (  ) for this operator in PHP. The basic logical use of this operator in a rough psuedocode could be Either the first condition is true  the second condition is true NOT ( ! ) Operators: you can use both ‘NOT’ and Exclamination Mark (Mathematician will call it Factorial Sign) sign ( ! ) for this operator in PHP. The basic logical use of this operator in a rough psuedocode could be First value is NOT equal to the second value Again do not confuse the use of these operators but just learn them by heart and I will use these all operators in my up coming articles for more complex PHP programmes and then your all doubts will be removed hopefully. This is one of the most important articles of this PHP Tutorials Series. Please concentrate hard on this articles and try to understand all issue discussed today and feel free to ask if you have any question and remember if you cannot understand this foundation lectures of PHP it will be very hard for you to survive when we will ‘BURN IT’ as I had promised with you that I will take you the Extreme PHP Programming and the Only rule of our game is “Don’t look behind” so you will not be able to go back to these articles again so learn these things now this article will make your strong foundation towards complex programming. Let’s end this lecture here. Regards,

Recent comments
23 hours 35 min ago
1 day 2 hours ago
1 day 7 hours ago
1 day 17 hours ago
2 days 38 min ago
2 days 51 min ago
2 days 5 hours ago
2 days 9 hours ago
2 days 11 hours ago
2 days 13 hours ago