Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP 5.4 and Facebook Hiphop compatibility

I was wondering does anyone know which of the features in PHP 5.4 are not supported in Facebook's Hiphop library. There's some questions on the Hiphop github wiki, such as this one, that very vaguely state :

HipHop does not currently support all PHP 5.4 features.

At the moment I just have to assume, for working purposes, all new features are not compatible as none are specified to work, if anyone has any insight on this that would be great, thanks in advance.

like image 344
boundless08 Avatar asked Oct 25 '12 15:10

boundless08


People also ask

What is the source code of hiphop?

HPHPc consists mainly of C++, C and PHP source codes, and it is free and open-source software distributed under the PHP License . The original motivation behind HipHop was to save resources on Facebook servers, given the large PHP codebase of facebook.com.

Why did HPHPc fail to support PHP?

Also, HPHPc did not fully support the PHP language, including the create_function () and eval () constructs, and it involved a specific time- and resource-consuming deployment process that required a bigger than 1 GB binary to be compiled and distributed to many servers in short order.

What version of PHP does XAMPP use?

upvoted, just for note Xampp 1.8.2 is using latest php 5.4 – Dark Cyber Mar 29 '17 at 14:47 Add a comment | 3 Answers 3 ActiveOldestVotes 16 Click hereto download XAMPP with PHP 5.4 version. Click hereto download older versions of XAMPP from SourceForge.


2 Answers

Stay away from the following:

Trait Declaration:

trait vehicleInfo {
    function getSpeed() { /*1*/ }
    function getWheels() { /*2*/ }
}

class Car extends Vehicle {
    use vehicleInfo;
    /* ... */
}

class Motorcycle extends Vehicle {
    use vehicleInfo;
    /* ... */
}

PHP 5.4 Array Instantiation:

$array = [
    "name" => "John Smith",
    "job" => "Basketweaver",
];

Function array dereferencing:

function small_numbers() {
    return array (0, 1, 2);
}

echo small_numbers()[0];

Class Member Access on Instantiation:

(new Foo)->bar();
like image 101
Daniel Li Avatar answered Oct 19 '22 10:10

Daniel Li


HipHop currently supports all of the features Daniel Li pointed out, except possible binary numbers. In fact, HipHop supported closures for years. The runtime is constantly improving, so keep an eye out in the future for a feature you're waiting for to show up.

If in doubt, and you have the time, just try using a feature and seeing if it works or not.

akrieger@vb:~/www$ hhvm features.php
2
akrieger@vb:~/www$ cat features.php
<?php

trait vehicleInfo {
    function getSpeed() { /*1*/ }
    function getWheels() { return [1,2,3,4]; }
}

class Vehicle {}

class Car extends Vehicle {
    use vehicleInfo;
    /* ... */
}

class Motorcycle extends Vehicle {
    use vehicleInfo;
    /* ... */
}

$getMotorcycleWheels = function() {
  return (new Motorcycle())->getWheels();
};

echo $getMotorcycleWheels()[1];
echo "\n";
akrieger@vb:~/www$
like image 40
Andrew Steven Krieger Avatar answered Oct 19 '22 11:10

Andrew Steven Krieger