Cazpa.com PHP Developer & Website Designer

7Nov/090

PHP Operators (Basic PHP Operators)

Now that we have the variables lets do some maths using operators, operators are the symbols that connect all the variables together.

Simple maths with PHP:

<?php
// Define variables
$number1 = 123;
$number2 = 2;

// Add
$total1 = $number1 + $number2;

// Subtract
$total2 = $number1 - $number2;

// Multiply
$total3 = $number1 * $number2;

// Divide
$total4 = $number1 / $number2;

// Modulus
$total5 = $number1 % $number2;
?>

Now lets use auto-increment and auto-decrement operators

Auto-increment

<?php
// Define variable
$total = 123;

// increment it
$total++;
// $total is now 124

// This is the same as
$total = $total + 1;
?>

Auto-decrement

<?php
// Define variable
$total = 123;

// decrement it
$total--;
// $total is now 122

// This is the same as
$total = $total - 1;
?>

No related posts.

About Daniel Smith

I am the boss around here, if you need anything then send me a message :))

Popular Content & Keywords

depositfiles hack,add update delete in php,warning: mail() [function mail]: smtp server response: 554 the message was rejected because it contains prohibited virus or spam content in,php tutorial deutsch,php define variable,,rails vs php performance,php add update delete,add update delete records from sql server using php,warning: mail() [function mail]: smtp server response: 554 the message was rejected because it contains prohibited virus or spam content,tutorial create contact form in dreamweaver php,ruby on rails vs php 2010,php tutorial // user registration w/ sql,send emails with a web form: php scripting,
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

You must be logged in to post a comment.

No trackbacks yet.

Powered by WordPress Lab