Michał Pipa
Last release: 5.3.29
Released: 1 March 2012
Released: 20 June 2013
Released: 28 August 2014
Next 5.x release
Online PHP & HHVM shell, execute code in 100+ different versions!
Generators provide an easy, boilerplate-free way of implementing iterators.
function getLinesFromFile($fileName) {
if (!$fileHandle = fopen($fileName, 'r')) {
return;
}
while (false !== $line = fgets($fileHandle)) {
yield $line;
}
fclose($fileHandle);
}
$lines = getLinesFromFile($fileName);
foreach ($lines as $line) {
// do something with $line
}
use A\Namespaced\ClassName;
// ClassName::class resolves to 'A\Namespaced\ClassName'
$mock = $this->getMock(ClassName::class);
$db = mysqli_connect();
try {
call_some_function($db);
} catch (Exception $e) {
mysqli_close($db);
throw $e;
}
mysql_close($db);
$db = mysqli_connect();
try {
call_some_function($db);
} finally {
mysqli_close($db);
}
2 ** 3
class MySQL implements DB {
public function query($query, ...$params) {
$stmt = $this-&pdo-&prepare($query);
$stmt-&execute($params);
return $stmt;
}
}
3 %% 2
HippyVM is an implementation of the PHP language using PyPy technology