TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

PHP

PHP Arithmetic Operators

Overview

In this tutorial, we will learn about PHP arithmetic operators. The arithmetic operators are as follows:

  • Addition (+)
  • Subtraction (-)
  • Multiplication (*)
  • Division (/)
  • Modulus (%)

Table

Arithmetic

Operator

Operation Example Expression

Result

+ Addition 4 + 5 9
– Subtraction 16 – 9 7
* Multiplication 12 * 3 36
/ Division 30 / 6 5
% Modulus 18 % 5 3

Example

Example PHP Program to show the operators in action.

<?php

// declare two variables a and b

$a = 11;
$b = 3;

//Perform operations

$sum = $a + $b;
$diff = $a – $b;
$product = $a * $b;
$div = $a / $b;
$mod = $a % $b;

//Output

echo “Addition is “.$sum;
echo “<br>”;
echo “Subtraction is “.$diff;
echo “<br>”;
echo “Multiplication is “.$product;
echo “<br>”;
echo “Division is “.$div;
echo “<br>”;
echo “Remainder is “.$mod;

?>

—

PHP Tutorials

PHP Tutorials on this website:

https://www.testingdocs.com/php-tutorials/

More Information on PHP

https://www.php.net/

Related Posts

Compoer Command line command

PHP /

Install Slim Framework on Windows

php download website

PHP /

Download and Install PHP on Windows

Composer Install Windows

PHP /

Composer Download on Windows

Apache conf file

PHP /

PHP 7 Configuration in Apache Server

testing php linux

PHP /

Testing PHP with Apache Server on Linux

‹ PHP String Variables› PHP If Statement

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version