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 trialNaida Ramic
12,789 PointsHi there in the implode function, why do we use the PHP_EOL as $glue, with or without it we get the same result. #TWEET
Where can the difference be seen, source, html var_dump?
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi Naida,
You won't see a difference on the rendered page whether you use PHP_EOL
or not. You will see the difference in the source html file.
After you run the combine_sort.php script it should create the "sorted.html" file in your "data/html" sub-folder.
If you open that file in workspaces then you should see that each option element is on its own line in the file. If you run the php script again but take out the PHP_EOL
, then you should see that all the option elements are on 1 long line in the "sorted.html"
Alternatively, you can right click on the webpage with the dropdown list and you should have an option to view the page source.
So the purpose of the line ending is to format the source file so it looks nicer but it doesn't affect the rendering of the page.