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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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.