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 Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Item Details and Redirection

Iulian Mirzac
Iulian Mirzac
3,083 Points

Parse error: syntax error, unexpected '<', expecting end of file in /home/treehouse/workspace/catalog.php on line 4

I am running this website building course. I am getting stuck onto an apparent simple error to be solved but i can't get to figure it out what the solution might be.

Here's the snapshot of the workspace. https://w.trhou.se/m2f0jk4qia

Of anyone can help i would be grateful.

3 Answers

Mikkel Rasmussen
Mikkel Rasmussen
31,769 Points

You need to close your php tag at the top of your catalog.php file or remove the <?php.

Matthias Margot
Matthias Margot
7,236 Points

You can nest PHP code in an HTML file however HTML syntax is not included in PHP and can't be interpreted as such inside a php tag.

<?php /*(DO NOT WRITE PLAIN HTML IN HERE ONLY OUTSIDE OF THIS)*/ ?>

If you wanted to print HTML to the file from a php code snippet you'd have to use any of the print functions like 'echo', 'print' or 'printf' and your HTML would have to be output as a string, not as plain HTML, php can't read that.

Iulian Mirzac
Iulian Mirzac
3,083 Points

I can't belive i wasted so much time on that. I thought about it, then took a glance over the code and i thought i closed the tag below. Thanks to you guys it works now.