Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics Unit Converter Creating a Unit Conversion Tool

John Diamond
John Diamond
766 Points

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.