Mar 20, 2014 at 10:43pm UTC
this is why i love facebook! hacklang.org . its statically typed php! this is going to get me back into web devving!
Mar 21, 2014 at 3:37am UTC
Apparently the closing tag ?> is not allowed, how are you supposed to generate HTML with it? The hard way?
Mar 21, 2014 at 4:07am UTC
http://stackoverflow.com/questions/4410704/why-would-one-omit-the-close-tag
The closing tag is often considered bad practice.
EDIT: You can generate HTML like normal. Directly from the interactive tutorial:
1 2 3 4 5 6 7 8 9 10 11 12
<?hh
// XHP is useful to build html (or xml) elements.
// The escaping is done automatically, it is important to avoid
// security issues (XSS attacks).
function build_paragraph(string $text, string $style): :div {
return
<div style={$style}>
<p>{$text}</p>
</div>;
}
Last edited on Mar 21, 2014 at 4:10am UTC
Mar 21, 2014 at 5:18am UTC
just out of curiousity, whats generating html the hard way?
Mar 21, 2014 at 6:40pm UTC
I have very little experience with PHP, but back when I was trying to learn it, this is what I knew:
Generating HTML with PHP the "easy" way:
<html>
<body>
<?php
for($i = 0; $i < 10; ++$i)
{
?>
<p>Hello!</p>
<?php
}
?>
</body>
</html>
Generating HTML with PHP the "hard" way:
<?php
echo("<html>");
echo("<body>");
for($i = 0; $i < 10; ++$i)
{
echo("<p>Hello!</p>");
}
echo("</body>");
echo("</html>");
The way Hack does it though looks nice, I didn't see that because I only went through the beginner half of the tutorials.
Last edited on Mar 21, 2014 at 6:40pm UTC
Mar 21, 2014 at 10:44pm UTC
oh i do it the easy way then