kuyarey Posted June 19, 2015 Share Posted June 19, 2015 My Mathematical operation is not working. Need help. Thank you in advance! P.S. Go easy on me I'm a noob in both the PHP language and these forums <?php //First ever serious php program starting from the basics echo "Hello World</br>"; print "<br>(278909887*4)</br>"; print "This should come out in another line"; ?> Output: Hello World (278909887*4) ====> This is what I'm talking about This should come out in another line Link to comment https://forums.phpfreaks.com/topic/296921-math-operation-syntax-help/ Share on other sites More sharing options...
Ch0cu3r Posted June 19, 2015 Share Posted June 19, 2015 The math operation needs to be done outside the string print "<br>" . (278909887*4) . "</br>"; Anything within a quotes is treated as-is. Only variables are expanded within double quoted strings. If you need to calculate/perform a function and use the result in a string you need to concatenate. Explained here http://php.net/manual/en/language.operators.string.php Link to comment https://forums.phpfreaks.com/topic/296921-math-operation-syntax-help/#findComment-1514376 Share on other sites More sharing options...
QuickOldCar Posted June 19, 2015 Share Posted June 19, 2015 To ensure the break works html,html5 and xhtml should use <br /> Personally I use echo because it can do more. echo (278909887*4) . "<br />"; I know this is a simple example, for the record using css is even better. Link to comment https://forums.phpfreaks.com/topic/296921-math-operation-syntax-help/#findComment-1514377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.