You are writing a PHP script and you need to add the values of two variables. How would you do this using operators?

  • $sum = $var1 + $var2;
  • $sum = $var1 - $var2;
  • $sum = $var1 * $var2;
  • $sum = $var1 / $var2;
To add the values of two variables in PHP, you would use the + operator. The expression $sum = $var1 + $var2; will add the values of $var1 and $var2 and store the result in the variable $sum. The + operator is the arithmetic addition operator in PHP and is used to perform addition operations on numerical values. Learn more: https://www.php.net/manual/en/language.operators.arithmetic.php
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *