Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

caterater and bouble qoutes help

Recommended Posts

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 2

This 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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 support


I 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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.