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 trial

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,772 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.