hisoka Posted March 28, 2016 Share Posted March 28, 2016 Plus sign is used in php for making white space. So How to make php echo white space between two strings using plus sign . For example : <?php $string = "hello"; $string1= "world"; echo $string+$string1; ?> I need a result as this hello world But how ? Link to comment Share on other sites More sharing options...
Ingolme Posted March 28, 2016 Share Posted March 28, 2016 The plus sign is to operate with numbers. If you want to join the strings together, use the concatenation operator, which is a dot. You can concatenate a literal string with a space in it to add a space between the other strings. echo $string1 . ' ' . $string2; An alternative way is to use double-quoted strings: echo "$string1 $string2"; 1 Link to comment Share on other sites More sharing options...
hisoka Posted March 28, 2016 Author Share Posted March 28, 2016 thank you Link to comment Share on other sites More sharing options...
euc Posted March 29, 2016 Share Posted March 29, 2016 Another way:- echo $string1 , ' ' . $string2; or echo $string1 , ' ' . $string2; // put in one space using this method you can make it as many spaces as you want eg echo $string1 , ' ' . $string2; //this will put in 3 spaces and echo $string1 , ' ' . $string2; //will put in 5 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now