Register

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
    Location
    St. Helens, England
    Posts
    70
    Member #
    37189
    Liked
    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:
    <?PHP
    $intval1 
    12;
    $intval2 12;

    echo 
    $intval1 $intval2;
    ?>

    0
    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:
    <?PHP
    echo (778*123) - (912+12);
    ?>

    94770
    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.

  2.  


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 11:20 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com