boudey Posted October 10, 2006 Posted October 10, 2006 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.
pyramids Posted October 10, 2006 Posted October 10, 2006 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> ';
Guest Posted October 10, 2006 Posted October 10, 2006 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. :)
pyramids Posted October 11, 2006 Posted October 11, 2006 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
Guest Posted October 11, 2006 Posted October 11, 2006 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.
boudey Posted October 11, 2006 Author Posted October 11, 2006 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.