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 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? ...... 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] 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 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 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 Link to comment https://forums.phpfreaks.com/topic/29054-math-in-var/#findComment-133618 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.