AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
HTML Tutorial

PHP Operator


PHP Tutorial » PHP Operator
  1. Arithmetic Operators
  2. Operator Precedence
  3. Assignment Operators
  4. Comparison Operators
  5. Bitwise Operators
  6. Error Control Operators
  7. Execution Operators
  8. Logical Operators
  9. Incrementing/Decrementing Operators
  10. Array Operators
  11. String Operators
  12. Type Operators

An operator is something that takes one or more expression and gives another value.


PHP Arithmetic Operators example


PHP arithmetic operators are used with numeric values to perform common arithmetical operations, such as: addition ($a + $b), subtraction ($a - $b), multiplication ($a * $b), division($a / $b), modulus($a % $b), exponentiation($a ** $b).

Example:
<!DOCTYPE html>
<html>
<body>
<h1>PHP Arithmetic Operators example</h1>

<?php

echo (4+8).",\n";
echo (24-6).",\n";
echo (12*3).",\n";
echo (12/3).",\n";
echo (4%8).",\n";
echo (2**6).",\n";

?>

</body>
</html>


PHP Assignment Operators, example

Basic PHP assignment operator is "=" (without quotes). Meaning: left operand gets set to the value of the assignment expression on the right.

Example of assignment operatore used in PHP:
1. x = y as: x =y, (x assigned y)
2. x += y as x = x + y, (Addition)
3. x -= y as x = x - y, (Subtraction)
4. x *= y as x = x * y, (Multiplication)
5. x /= y as x = x / y, (Division)
6. x %= y as x = x % y, (Modulus)

Example:
<!DOCTYPE html>
<html>
<body>
<h1>PHP Assignment Operators</h1>

<?php

$x = 125;
echo $x.",<br />";

$y = 25;
$y += 110;
echo $y.",<br />";

$z = 55;
$z -= 32;
echo $z.",<br />";

$a = 10;
$b= 6;
echo $a * $b.",<br />";

?>

</body>
</html>


PHP Increment / Decrement Operators

The PHP increment operators - used to increment a variable's.

The PHP decrement operators - used to decrement a variable's value.

1. ++$x : Increments $x by one, then returns $x
2. $x++ : Returns $x, then increments $x by one
3. --$x : Decrements $x by one, then returns $x
4. $x-- : Returns $x, then decrements $x by one

Example: PHP Increment / Decrement Operators
<!DOCTYPE html>
<html>
<body>
<h1>PHP Increment / Decrement Operators</h1>

<?php

$x = 14;
echo ++$x.",<br />";

$y = 22;
echo $y++.",<br />";

$z = 12;
echo --$z.",<br />";

$w = 11;
echo $w--.",<br />";

?>

</body>
</html>




php operator, precedence, =, or, modulo, not supported for string, overload, and, in variable, double question marq
PHP Operator Types - php tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Home
PHP Introduction
PHP Install
PHP Syntax
PHP Variables
PHP Echo and Print
PHP Data Types
PHP String Function
PHP Constants
PHP Operator Types
PHP If Else and Elseif
PHP Switch
PHP While Loops
PHP Loop For Do Foreach
PHP Array
Convert Array to String
PHP Function
PHP GET and POST
PHP Date/Time Functions
PHP Login
PHP Delete Element
PHP eregi_replace()
PHP mysql_query()
PHP Errors to Display
PHP Loop For Do Foreach

PHP forms
PHP Form Example
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Warning: mysqli_fetch_array() expects pa...
HTML div style property...
CSS bold, Style, Property...
CSS background image size to fit screen ...
PHP convert array to string with commas...
PHP array to comma separated string with...
How to put text in image HTML...
How to insert text in html code using ja...
PHP array_key_exists() Function...
Bootstrap Templates...
Bootstrap Text...
Bootstrap Accordion...
Bootstrap Scrollspy...
Bootstrap Carousel...
Bootstrap Modal...
Bootstrap Responsive Layout...
Bootstrap Fluid Layout...
Bootstrap Fixed Layout...
Bootstrap Grid...
Bootstrap Input...