Howdy_McGee Posted August 31, 2010 Share Posted August 31, 2010 I just started learning PHP and I got a not very helpful book :/ ...So here's my code for starters <?php $num1 = 18; $num2 = 18 + 5; $test = array('Alex', 'David', 'Miller'); echo "First Number is " + $num1 + "."; echo "<br />"; echo "That number Plus 5 is " + $num2 + "."; echo "<br />"; echo "The first name in the array is " + $test['0']; echo "<br />"; echo "The second name in the array is " + $test['1']; echo "<br />"; echo "The third name in the array is " + $test['2'];?> My problem is that when I display it, it shows 0 instead of echo-ing the text. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 31, 2010 Share Posted August 31, 2010 The concatenation operator in PHP is a period, a plus is addition. Link to comment Share on other sites More sharing options...
ShadowMage Posted August 31, 2010 Share Posted August 31, 2010 The '+' is not the concatenation operator, it is an arithmetic operator. The '.' is the concatenation operator. So your code should be:echo "First Number is ".$num1.".";.....etc Link to comment Share on other sites More sharing options...
Howdy_McGee Posted August 31, 2010 Author Share Posted August 31, 2010 Ah that works. Thanks guys! Link to comment Share on other sites More sharing options...
thescientist Posted August 31, 2010 Share Posted August 31, 2010 already time for a new book...? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.