If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Member Cranavvo's Avatar
    Join Date
    Sep 2013
    St. Helens, England
    Member #
    11 times

    PHP Tutorial 4 - Mathematical Operators

    This is a follow-up to my previous tutorial: PHP Tutorial 3 - Functions. It's wise you should read the last tutorial before you come onto the next one.

    Mathematical Operators are easy in PHP. Like in most languages they are not done by words but with various symbols:
    • / - Division
    • + - Addition
    • - - Subtraction
    • * - Multiplication

    Variables with integer values can be placed into mathematical problems, for e.g.

    PHP Code:
    $intval2 12;

    $intval1 $intval2;

    Plus if you've heard of BIDMAS(Brackets, Indices, Division, Multiplication, Addition, Subtraction) which splits mathematical problems up in order of their operations, for e.g. 778*123-912+12 can be placed into PHP like:

    PHP Code:
    echo (778*123) - (912+12);

    Maths will come up A LOT in PHP which is why it's important you learn some maths while you're at-it. Thanks for reading.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 09:36 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: