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 trialAdebayo Ojo
23,661 PointsPlease explain this....
At what instance can we have a code like this, i.e. having a colly brace between a php opening and closing tag:
<?php } ?>
1 Answer
Philip G
14,600 PointsHi Adebayo,
It is used if you mix PHP and HTML. Instead of printing the HTML to the page and having to escape the string, you can use it this way:
<?php
if($some_var == "My Text")
{
?>
<a href="google.com">Click here<a/>
<?php } ?>
The code if you choose to escape the string would look somehow like this:
<?php
if($some_var == "My Text")
{
print("<a href=\"google.com\">Click here<a/>");
}
?>
You see, It is much more comfortable to use the technique from the first example, especially if you have tons of HTML (Though in this case I would use a Templating Engine :)
If there is anything that's still not clear to you, don't hesitate to ask me!
Best Regards, Philip
Kevin Korte
28,149 PointsGood example, I upvoted!
Philip G
14,600 PointsThanks!
Ashu Singh
Courses Plus Student 38 PointsAshu Singh
Courses Plus Student 38 Points<?php ?> is supposed to hold php scripts