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

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.


Upload Image, display, edit and delete i...
Login Form with Image background...
How to Create an Image with Transparent ...
Portfolio Gallery Website with filtering...
Simple pagination script PHP MySQLi...
Center Image in div...
Image Hover Overlay Fade...
Sticky image / element / div on scroll...
Responsive images...
Create rounded image in HTML CSS...
Add border around image...
Position Text Over an Image HTML CSS res...
Create a Slideshow Images Gallery...
Create a Sticky Sidebar...
Search bar using CSS HTML...
Shrink Navigation Menu on Scroll...
How to Create Accordion HTML Templates...
Dropdown menu in the navigation bar...
Responsive Top Navigation Bar with mobil...
Split horizontal navigation bar...