How to use assignment operators to assign values to between variables using addition,multiplication, subtraction, modulus, divide operator.
Assignment operator also known as Equal To ( = ) symbol in every programming language. This operator is used to transfer one variable value to another by using Arithmetic operators or without them. Assignment operator works on a simple formula that the left variable operand gets the right side of after assignment variable value. This operator works with all the Arithmetic operators like addition, multiplication, subtraction, modulus and divide. So here is the complete step by step tutorial for PHP Assignment Operators example tutorial.
PHP Assignment Operators example tutorial.
Code for Assignment-program.php file.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>PHP Assignment Operators example tutorial</title> </head> <body> <?php //Assigning direct value to $one variable using assignment operator. $one = 10; //Assigning direct value to $two variable using assignment operator. $two = 2; //Assigning left operand with right variable value. $three = $one; //Addition $three = $one + $two; echo "Addition using Assignment operator = ".$three.'</br>'; //Multiplication $three = $one * $two; echo "Multiplication using Assignment operator = ".$three.'</br>'; //Subtraction $three = $one - $two; echo "Subtraction using Assignment operator = ".$three.'</br>'; //Division $three = $one / $two; echo "Division using Assignment operator = ".$three.'</br>'; //Modulus $three = $one % $two; echo "Modulus using Assignment operator = ".$three.'</br>'; ?> </body> </html>
Screenshot: