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 File Handling with PHP Basic File Handling Writing Files All at Once

Hi 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

Hi 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.