statically typed php :D

this is why i love facebook! hacklang.org . its statically typed php! this is going to get me back into web devving!
Apparently the closing tag ?> is not allowed, how are you supposed to generate HTML with it? The hard way?
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
just out of curiousity, whats generating html the hard way?
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
oh i do it the easy way then
Topic archived. No new replies allowed.