In PHP, it is not uncommon to see PHP and HTML intermixed in the same file.
<head></head> <body> Hello, today is <?php echo date('l, F jS, Y'); ?>. </body> </html>
<head></head> <body> Hello, today is Thursday, November 12th, 2015. </body> </html>
The above PHP code will run just fine in HHVM. At the command line, the output will be the raw HTML with the proper date included.
The problem becomes when you try to replace
<head></head> <body> Hello, today is <?hh echo date('l, F jS, Y'); ?>. </body> </html>
Fatal error: HH mode: content before <?hh (Line: 3, Char: 16) syntax error, unexpected T_HH_ERROR, expecting $end in /data/users/joelm/user-documentation/guides/hack/60-unsupported/04-html-examples/html-hack.php on line 1
And the problem is confusing. The typechecker will basically throw its hands up and give you "No Errors!", no matter what you put after the
<?hh, even in strict mode. That's great, right? Nope. The typechecker doesn't even understand this type of file and, on top of that, this code won't even run in HHVM. You will get a fatal error complaining that there is unknown content before the
<?hh must always be the first 4 characters seen.
If you really want to mix HTML-like elements with your Hack code, XHP was made especially for that. And, it is typecheckable.