Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics Unit Converter Creating a Unit Conversion Tool

My workspace echoes code entered as opposed to actually executing when run from comm line. How do I stop this?

<? php //number in pounds we want to convert to kg $pounds = 140; //floating point value for lb to kg conversion $lb_to_kg = 0.453592; //use above variables to calc pounds * kg conversion $kilograms = $pounds * $lb_to_kg; //display lb to kg echo "Weight"; echo $pounds; echo " lb = "; echo $kilograms; echo "kg";

//number in miles we want to convert to km $miles = 2.5; //floating point value for mile to km conversion $mile_to_km = 1.60934; //use above variables to calc miles * km coversion $kilometers = $miles * $mile_to_km; //display miles to km echo "Distance: "; echo $miles; echo " miles = " echo $kilometers"; echo " km";

?>

When this code is run using the command 'php units.php', it prints all of this text rather than executing and returning the calculated sum.

1 Answer

In the opening php tag, <? php should be <?php without the space after the ?.