Jump to content

read constant value in table cell


Velodrome

Recommended Posts

Help!
I'm extremely new to php and have a very simple problem. I cannot see my constant value in a table cell.
Please somebody help me thank you. 

part of the code:

define("CAR", "Volvo");

echo("<table border=1>");
echo("<tr>");
echo("<th>Car</th><th>Model</th>th><th>Consumption</th><th>Retail Price</th>");
echo("</tr>");
echo("<tr align=center>");
echo("<td>CAR</td>");                          [color=red]// This is where i want my constant value to be displayed[/color]
echo("<td>$model1</td>");
echo("<td>$consumption1</td>");
echo("<td>$price1 &#8364</td>");
echo("</tr>");
Link to comment
https://forums.phpfreaks.com/topic/28888-read-constant-value-in-table-cell/
Share on other sites

PHP can't distinguish a constant from a regular literal string when it is enclosed in quotes.

Use the following instead:
[code]<?php
echo "<td>" . CAR . "</td>";
?>[/code]

BTW, you don't need the parenthesis when using the echo statement.

Ken

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.