HELP: echo not outputing variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Matt FT
Forum Newbie
Posts: 1
Joined: Fri Oct 24, 2003 8:35 am

HELP: echo not outputing variable

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
Post Reply