redarrow Posted March 11, 2006 Share Posted March 11, 2006 Please exsplain to me what is the diffence of useing these two examples one looks odd to me but are fully working examples.example 1$name assign to peter and then to join the string together i use a caterater, to echo the data i use two bouble qoutes then a caterater and a semi colon.It looks relly wrong to me but does what it suppose to, Why does it work, Also see the secound example easer to understand but being shown in my course the example here.[code]<?$name = "peter";echo "my name is ".$name;?>[/code]example 2This example works fine and looks correct to me, But is it as i am being shown the above to learn.[code]$name = "peter";echo "my name is ".$name." ";[/code]Are the both examples valid or not. Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 11, 2006 Share Posted March 11, 2006 concatenator :)As you noted, either works, but in the second example the extra blank space added to the end of what's to be echo'd is pointless. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 11, 2006 Author Share Posted March 11, 2006 [!--quoteo(post=353977:date=Mar 11 2006, 07:18 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Mar 11 2006, 07:18 PM) [snapback]353977[/snapback][/div][div class=\'quotemain\'][!--quotec--]concatenator :)As you noted, either works, but in the second example the extra blank space added to the end of what's to be echo'd is pointless.[/quote]Thank you andy for your supportI will use this method for echoing out one varable then in a string cheers.[code]<?$name = "peter";echo "my name is ".$name;?>[/code]But if i was to echo out two varables i would have to use this example thats why i asked cheers[code]<?$name = "peter";$age = 31;echo "my name is ".$name." and my age is ".$age." years old";?>[/code]As you can see why i asked cheers.Solved unless any advise is needed for me to understand more thank you for your support. 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.