Page 1 of 1

See if you can spot the error

Posted: Wed May 26, 2010 7:16 pm
by soma56
This one works:

Code: Select all

<h1>This Old Man with Arrays</h1>
<?php 
$place = array(
  "",
  "on my thumb",
  "on my shoe",
  "on my knee",
  "on a door");
  
//print out song
for ($verse = 1; $verse <= 4; $verse++){
print <<<HERE
 <p>
 This old man, He played $verse <br />
 He played knick-knack $place[$verse] <br />
 ...with a knick, knack, paddy-whack <br />
 give a dog a bone <br />
 This old man came rolling home 
 </p>
HERE;
  } // end for loop

?>
This one doesn't:

Code: Select all

<h1>This Old Man with Arrays</h1>
<?php 
$place = array(
  "", 
  "on my thumb",
  "on my shoe",
  "on my knee",
  "on a door");

//print out song
for ($verse = 1; $verse <= 4; $verse++){
print <<<HERE
 <p>
 This old man, He played $verse <br />
 He played knick-knack $place[$verse] <br />
 ...with a knick, knack, paddy-whack <br />
 give a dog a bone <br />
 This old man came rolling home 
 </p>
HERE; 
  } // end for loop
  
?>
what's different?

Re: See if you can spot the error

Posted: Wed May 26, 2010 7:39 pm
by mikosiko
in the second one remove the space that you have after

Code: Select all

HERE;