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? Link to comment https://forums.phpfreaks.com/topic/292356-novice-please-help/ Share on other sites More sharing options...
Ch0cu3r Posted November 8, 2014 Share Posted November 8, 2014 Concatenate the answer echo "$x+$y = " . ($x+$y); // Output 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 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. 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. Link to comment https://forums.phpfreaks.com/topic/292356-novice-please-help/#findComment-1496105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.