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 trialMartin Nordström
6,807 Points"Hello, World!" is not displaying on my page?
I know that I've typed the code right. But it still dosen't display??
Konrad Pilch
2,435 PointsWhats happening though? Can you say in more details pelase? Does the page goes all blank? or soemthing? Could you show us the code?
Simon Coates
28,694 PointsThe correct code for outputting hello world would be:
<?php
echo "hello world";
You can try running your code in a PHP sandbox (eg http://sandbox.onlinephpfunctions.com/)to verify correctness. Otherwise, we need to know the details of how your code is not working (environment, whether you're accessing the right page etc.) As Konrad Pilch notes, i did omit the closing tag, and i don't doubt there are points at which doing so is not advised. I'd also note that online sandboxs aren't fully featured, but should be okay for a hello world program, or debugging small fragments of PHP code.
Konrad Pilch
2,435 PointsSimon, thats partially correct - depending on the situation.
The code should open PHP tags, and close, in between the code. What you have, it would break my whole aplication where im trying to display user username. Its good for things like classes because thers no html, only PHP, so you don't need to close the PHP tag, and it's better not to.
1 Answer
Martin Nordström
6,807 PointsIt's a bit embarrassing.. I forgot to change "index.html" to "index.php"....
Thanks anyways!
Robert Cooper
22,704 PointsI did the exact same thing and it took me a while to figure it out...haha
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherLet´s check the obvious first. Have you saved your file, refreshed the page in the browser and as a last resort tried clearing the browser cache and refreshing again? Oh and you're doing this in workspaces correct? If you're doing it locally you need to set up a php server.