jwk811 Posted December 1, 2006 Share Posted December 1, 2006 I want to make a variable like this: $var = ($var / 1000000) * 8 .. but im having problems with that Quote Link to comment https://forums.phpfreaks.com/topic/29054-math-in-var/ Share on other sites More sharing options...
Zane Posted December 1, 2006 Share Posted December 1, 2006 problems like? ...... Quote Link to comment https://forums.phpfreaks.com/topic/29054-math-in-var/#findComment-133115 Share on other sites More sharing options...
marcus Posted December 1, 2006 Share Posted December 1, 2006 you can't use a variable inside a variable that isn't predefined.you can do[code]<?php$num = "firstnumber";$math = "($num / number) * 8)";echo $math;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/29054-math-in-var/#findComment-133131 Share on other sites More sharing options...
jwk811 Posted December 1, 2006 Author Share Posted December 1, 2006 you see but that doesnt work.. it actually writes out the equation and without the quotes is an error Quote Link to comment https://forums.phpfreaks.com/topic/29054-math-in-var/#findComment-133612 Share on other sites More sharing options...
craygo Posted December 1, 2006 Share Posted December 1, 2006 [code]<?php$num = 20;$math = ($num / 200) * 8;echo $math;?>[/code]Or[code]<?php$num = 20;$num2 = 5;$math = ($num / $num2) * 8;echo $math;?>[/code]Double quote will treat things as strings instead of intergers.Ray Quote Link to comment https://forums.phpfreaks.com/topic/29054-math-in-var/#findComment-133617 Share on other sites More sharing options...
jwk811 Posted December 1, 2006 Author Share Posted December 1, 2006 yeah but that shows an error saying unexpected (.. i just broke it down into smaller equations and thats working well, thanks anyways Quote Link to comment https://forums.phpfreaks.com/topic/29054-math-in-var/#findComment-133618 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.