Reputation: 696
HHVM is a new run time for PHP. I had installed hhvm on Ubuntu.
But I got a doubt that can I write php code in .hhvm file.
<?php
echo "Hello HHVM with PHP";
?>
Or I have to install hack and write code as shown below
<?hh
echo "Hello HHVM with HACK";
?>
Which is correct way to work with HHVM(with PHP or HACK).
If I went completely wrong please give me the difference between HACK, HHVM, PHP.
Upvotes: 1
Views: 292
Reputation: 7260
HHVM is a runtime engine for two programming languages, PHP and Hack. It is what actually executes your code and produces results, just like the Python interpreter or Node.
When HHVM runs your PHP code, its behavior should be identical to running it on the PHP5 engine from php.net, the one you are probably used to using. Any deviation in behavior is a bug (with one or two very minor exceptions). In other words, your existing PHP should run the same on HHVM as with the PHP5 engine. You don't have to, and probably shouldn't, give your code a different extension such as .hhvm
in your example. Just write PHP code, ending in .php
. (HHVM doesn't actually care about the file extension, but your webserver probably does.)
For getting started running PHP on HHVM, you should check out the "Getting Started" page on the HHVM wiki. It talks about how to get a webserver such as nginx to talk to HHVM -- the process is nearly the same as with php-fpm.
HHVM also supports a second programming language, Hack, which is a dialect of PHP initially developed at Facebook. Hack includes features such as a static type system and asynchronous functions, and also removes some of the nastier or harder to deal with bits of PHP. All of the necessary components to run Hack code is included in the standard HHVM distributions -- HHVM supports both the PHP and Hack languages out of the box. The HHVM documentation describes how to get started with Hack.
But again, Hack is a separate language from PHP. HHVM will run both, including unmodified PHP with all its features. Even though some things are unsupported in Hack, they all work just fine in PHP running on HHVM.
Upvotes: 2