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
Thomas Karchesy
596 PointsMixing php and html comment tags?
How are html comment tags (i.e. <!-- --> ) interpreted in php?
Are php comment tags used only within php code blocks?
2 Answers
Luksy Breezy
268 Pointsphp comments can only be used within the php code block. so also is html.
consider this
<!-- Main navigations.... html comment outside php code block --> <nav> <ul> <li> <?php // echo homepage .... php comment inside php code block echo $homepage ?> </ul> </nav>
Curtis Murley
2,766 PointsYou can comment within php by adding // at the beginning of your comment. No need to have html comments within php
<!-- set page title . . . this is a html comment -->
<title>
<?php
// dynamically adds webpage title . . . this is a php comment
echo $homepage
?>
</title>