Barry2014 Posted November 8, 2014 Share Posted November 8, 2014 <?PHP $x="10"; //Variable $y="7"; //Variable echo("$x+$y = 17") // Output ?> How do I get the correct answer to output without putting it in myself like how I did? Quote Link to comment https://forums.phpfreaks.com/topic/292356-novice-please-help/ Share on other sites More sharing options...
Solution Ch0cu3r Posted November 8, 2014 Solution Share Posted November 8, 2014 Concatenate the answer echo "$x+$y = " . ($x+$y); // Output Quote Link to comment https://forums.phpfreaks.com/topic/292356-novice-please-help/#findComment-1496084 Share on other sites More sharing options...
Barry2014 Posted November 8, 2014 Author Share Posted November 8, 2014 Thanks, I use open brackets to start the string and it still work but what is best practice. You - echo "$x+$y = " . ($x+$y); // Output me - echo ("$x+$y = " . ($x+$y)); // Output Quote Link to comment https://forums.phpfreaks.com/topic/292356-novice-please-help/#findComment-1496087 Share on other sites More sharing options...
Ch0cu3r Posted November 8, 2014 Share Posted November 8, 2014 The parenthesises are optional. Quote Link to comment https://forums.phpfreaks.com/topic/292356-novice-please-help/#findComment-1496101 Share on other sites More sharing options...
Barry2014 Posted November 8, 2014 Author Share Posted November 8, 2014 Ok thanks. Quote Link to comment https://forums.phpfreaks.com/topic/292356-novice-please-help/#findComment-1496105 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.