Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simple PHP question - display variable


boudey

Recommended Posts

Posted

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.

Posted

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>
';

Posted

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. :)

Posted
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

Posted
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.
Posted

Thanks Jeff.

 

It works fine.

 

I am learning PHP as I am facing problems to be solved. :)

 

Don?t know how to close the POST and label it as solved, but ... Thanks

 

MB

Archived

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

×
×
  • Create New...