if anyone can answer this, i would be grateful. the above source is returning 31 on my echo, i know im missing something, cause normal logic says this = 40, thanks in advance!
why is this code returning 31?
Moderator: General Moderators
-
southeastweb
- Forum Newbie
- Posts: 14
- Joined: Sun Mar 21, 2004 3:28 am
- Location: Florida
why is this code returning 31?
$variable50 = 3+7 * 4;
if anyone can answer this, i would be grateful. the above source is returning 31 on my echo, i know im missing something, cause normal logic says this = 40, thanks in advance!
if anyone can answer this, i would be grateful. the above source is returning 31 on my echo, i know im missing something, cause normal logic says this = 40, thanks in advance!
-
aleigh
- Forum Commoner
- Posts: 26
- Joined: Thu Mar 25, 2004 11:06 am
- Location: Midwestern United States
- Contact:
Re: why is this code returning 31?
What you really mean is (3+7)*4. You can learn more at:southeastweb wrote:$variable50 = 3+7 * 4;
if anyone can answer this, i would be grateful. the above source is returning 31 on my echo, i know im missing something, cause normal logic says this = 40, thanks in advance!
http://us4.php.net/manual/en/language.o ... precedence
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
southeastweb
- Forum Newbie
- Posts: 14
- Joined: Sun Mar 21, 2004 3:28 am
- Location: Florida
yup
i knew it was something simple, never fails. thanks for the help, going to get my precedence straight! Frodo
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
southeastweb
- Forum Newbie
- Posts: 14
- Joined: Sun Mar 21, 2004 3:28 am
- Location: Florida
Exponent?
does exponent refer to the mathmatical term? does anyone know how to use this, or an example, im trying to figure it. thanks guys!
PEDMAS
People Eat Dollar Meals At Subway!
PEDMAS
People Eat Dollar Meals At Subway!
-
southeastweb
- Forum Newbie
- Posts: 14
- Joined: Sun Mar 21, 2004 3:28 am
- Location: Florida
my mistake not PEDMAS!
just to clear myself, i know what an exponent is, just wondering how you use it in php, and example? im heading to php.net thanks for PEMDAS
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
function i wrote:
I'm sure PHP has a function though..
Code: Select all
function raise($num, $exp){
$value = 1;
for($i=0;$i<$exp;$i++){
$value = $value * $num;
}
return $value;
}-
aleigh
- Forum Commoner
- Posts: 26
- Joined: Thu Mar 25, 2004 11:06 am
- Location: Midwestern United States
- Contact:
It does; pow()LiLpunkSkateR wrote:function i wrote:I'm sure PHP has a function though..Code: Select all
function raise($num, $exp){ $value = 1; for($i=0;$i<$exp;$i++){ $value = $value * $num; } return $value; }
