image


Valora:  2.5/5
Inicio » PHP » PHP Tutorial » Operators




Arithmetic Operators

PHP operators are very similar to C and JavaScript operators, if you know these languages, operators will be familiar and easy to recognize.

These are the operators that can be applied to variables and numeric constants.









Operator Name Example Description
+ Addition 5 + 6 Adds two numbers
- Subtraction 7 - 9 Subtracts two numbers
* Multiplication 6 * 3 Multiplies two numbers
/ Division 4 / 8 Divides two numbers
% Modulus 7 % 2 Returns the remainder from dividing both numbers, in this example the result is 1.
++ Increment $a++ Adds 1 to the content of a variable.
-- Decrement $a-- Subtracts 1 to the content of a variable.


<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
   <title>PHP Example</title>
</head>
<body>
<?php
   $a = 8;
   $b = 3;
   echo $a + $b,"<br>";
   echo $a - $b,"<br>";
   echo $a * $b,"<br>";
   echo $a / $b,"<br>";
   $a++;
   echo $a,"<br>";
   $b--;
   echo $b,"<br>";
?>

</body>
</html>

Execute View code






WebEstilo.com - Introduzca su e-mail y conozca las novedades. No hacemos Spam.
Google
  Web WebEstilo.com   
 
Valid HTML 4.01!
Última modificación:24 de Diciembre de 2004. Spain - España.
© 1998-2004 por Joaquin Gracia. Todos los derechos reservados.