Page 1 of 1

HELP: echo not outputing variable

Posted: Fri Oct 24, 2003 8:35 am
by Matt FT
Hi there people. I just can't get this bit of code to work. The variables are definatly set, as they work elsewhere in the script. Here is the section causing me problems. It outputs $artist2 and %listid2 insted of the variables.

Code: Select all

<? if ($list_no >= 2) 
		  echo'<tr> 
		      <td colspan="2"> <span class=".aria_text"> 
              <input type="checkbox" name="list_id" value="$listid2" checked>
              Receive the $artist2 newsletter</span></td>
          </tr>'; ?>




Any help greatly appreciate!

Matt

Posted: Fri Oct 24, 2003 8:41 am
by volka
substitution of variables only takes place in double-quoted string literals or with heredoc-syntax

Code: Select all

<?php
$var = 4;
echo "2 + 2 = $var  "; // double qouted
echo <<< EOL
2 + 2 = $var  
EOL;
echo '2 + 2 = $var  '; // single quoted
echo '2 + 2 = ', $var; // single quoted, but variable outside
?>
see also: http://www.php.net/manual/en/language.types.string.php