Jump to content

Math Help


Crew-Portal

Recommended Posts

This is not really a help topic but since this board gets not that much traffic I decided to post pretty much everything I know about PHP math here so that n00bs can read this and maybe itll help them!

 

PHP math is very simple to use all you need to do is echo (2 + 2); and it will display 4 you can use these equasions for /,*,-,+ and probably alot more!

if you are calling a equasion form another file just put your math equasion in a file called math.php and use include_once. When trying to make an equasion for a random event you need a $varialbe for example

<?php
$randmath = rand (0,100);
echo ($randmath / 453 + 654);
?>

This will display alot of numbers. First it will take a random number between 0 and 100 and divide by 453 and add 654. This will produce alot of numbers so to round it you just do

<?php
$randmath = rand (0,100);
echo round($randmath / 453 + 654);
?>

This will round it to a whole number. But to round it to a fraction you do

<?php
$randmath = rand (0,100);
echo round($randmath / 453 + 654, 2);
?>

This will round it to the 2 nearest decimal places like 56.45 or 456.43 ect...

I will post more about PHP Math if this topic is not locked or deleted within 2 days! Enjoy math (Woah  :o that sounded wierd! Never thought I would say that EVER!)

Link to comment
Share on other sites

http://php.net/operators.arithmetic

http://php.net/math

http://php.net/bc

That's what you need to know.

 

Something like 1+2 is not an equation (note spelling). It means when two things are equal, but if you only have one thing (i.e. 1+2) then it cannot be an equation. Something like 1+2=3 or 1+x=3 would be an equation. What you are talking about are expressions. Equations are used to state equality between two expressions.

Link to comment
Share on other sites

  • 3 years later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.