PHP
  Home arrow PHP arrow Page 3 - PHP Operators
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

PHP Operators
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 18
    2007-10-31

    Table of Contents:
  • PHP Operators
  • Assignment Operators
  • Arithmetic Operators
  • Incremental Operators
  • Better by Comparison
  • Logical Operators

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PHP Operators - Arithmetic Operators


    (Page 3 of 6 )

    You have been using most of the arithmetic operators since childhood. That and your fingers and toes. But don't worry; PHP is smarter than you. It's prettier than you. And according to some of the other programming languages, it really gets around. ASP is really jealous, but don't tell it I said so.

    Let's look at some examples.


    <html>

    <body>


    <?php


    $add = 1 + 0;

    $subtract = 2 - 1;

    $multiply = 1 * 1;

    $division = 2 / 2;

    $modulus = 5 % 2;


    echo $add;

    echo $subtract;

    echo $multiply;

    echo $division;

    echo $modulus;


    ?>


    </body>

    </html>

    The above code would print out all the values of our variables:


      1

      1

      1

      1

      1

    A Brief Note About My Dear Friend...The Modulus

    The majority of the tutorials I've read on PHP never really explained Modulus in simple terms and so I never knew what it did. Maybe I'm just an idiot. But if there are other idiots out there, then you are in luck, because I am going to put this in very simple terms. Modulus gives you the remainder in division. Period. If I divide 2 / 2, there is no remainder. If I divide 3 /7 there is a remainder of 1. Modulus would return that 1.

    More PHP Articles
    More By James Payne


       · Hey thanks for taking the time to read my article on PHP Operators- I hope it was...
       · . . . but, if I remember Correctly, it's Sisko, not Cisco. And Archer is way...
       · I don't recall if it is in PHP4, but the === operator can be quite valuable.
       · Don't you need some backslashes and an ending quote?echo "<h1...
     

       

    PHP ARTICLES

    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway