Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simple PHP question - display variable


boudey

Recommended Posts

Hi,

I need to have a variable - CAT - shown on a page. This is a variable defined in the english.php file.

I know how to display it when the surrounding code is HTML:

 

<?php echo CAT; ?>

 

But, when I am in some PHP code already like:

 

echo '

<table cellspacing=0 cellpadding=0 width=437 align=center>

<tr><td background=images/m22.gif width=437 height=29 valign=top>

 

<table cellspacing=0 cellpadding=0>

<tr>

<td height=8></td></tr>

<tr><td width=25></td><td class=ch6> CAT </td></tr>

</table>

';

 

what is the syntax to display the variable CAT?

 

Thanks much for the support.

Link to comment
Share on other sites

try:

 

echo '
<table cellspacing=0 cellpadding=0 width=437 align=center>
<tr><td background=images/m22.gif width=437 height=29 valign=top>
<table cellspacing=0 cellpadding=0>
<tr>
<td height=8></td></tr>
<tr><td width=25></td><td class=ch6>' .  CAT . ' </td></tr>
</table>
';

Link to comment
Share on other sites

The other alternative is to use double quotes instead of single. When using single quotes the variable NAME is printed, not its value.

 

Checkout more on echo here. :)

Link to comment
Share on other sites

The other alternative is to use double quotes instead of single. When using single quotes the variable NAME is printed, not its value.

 

Checkout more on echo here. :)

 

true statement, but it doesn't apply here since no variables are being quoted.

 

here is the manual ex:

echo 'foo is $foo'; // prints foo is $foo

echo "foo is $foo"; // prints foo is foobar

Link to comment
Share on other sites

true statement, but it doesn't apply here since no variables are being quoted.

Yes, apologies for that. In the OP I must've only taken in the former part of the following and not the latter (ie. the mention of "define" should've given it away :)). It's not a variable at all but rather a constant. :) :blush:

I need to have a variable - CAT - shown on a page. This is a variable defined in the english.php file.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...