Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °
| |
|
|
You are not logged in. #1 2011-01-18 17:14:33
Basic PHP Math QuestionI'm going through a php tutorial right now and this math example below is driving me nuts. The exmaple was "((1 + 2 + $var1) * $var2) / 2 - 5", and all the rest of the code below is just me trying to figure it out. Code:<?php
$var1 = 3;
$var2 = 4;
?>
$var1 = 3;<br />
$var2 = 4;<br /><br />
<br />
<h1> ((1 + 2 + $var1) * $var2) / 2 - 5 = <?php echo((1 + 2 + $var1) * $var2) / 2 - 5; ?><br /> </h1>
<hr />
<br />
<br />
LEFT SIDE:<br />
(1 + 2 + $var1) * $var2 = <?php echo ((1 + 2 + $var1) * $var2); ?><br />
<br />
RIGHT SIDE:<br />
2 - 5 = <?php echo 2 - 5; ?><br />
<br />
24 / -3 SHOULD BE:
<h1>24 / -3 = <?php echo 24 / -3; ?><br /></h1>That spits out: #2 2011-01-18 17:51:34
Re: Basic PHP Math QuestionHi simy202,
This evaluates to : (((1 + 2 + 3)*4)/2) - 5 = ((6*4)/2) - 5 = 12 - 5 = 7.
The left of '=' sign is called Left hand side, not the left of '/' sign... Last edited by gAr (2011-01-18 17:55:20) "Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha? "Data! Data! Data!" he cried impatiently. "I can't make bricks without clay." #3 2011-02-09 09:36:45
Re: Basic PHP Math QuestionI am quite confused. How can you expect the PHP code to work if it is outside <?php and ?> ? Give me a lever long enough and a fulcrum on which to place it, and I shall move the world. -Archimedes My maturity level depends on the people I am around. #4 2011-02-09 13:38:21
Re: Basic PHP Math QuestionHi Shivamcoder3013, "Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha? "Data! Data! Data!" he cried impatiently. "I can't make bricks without clay." |