Michał Pipa
Last release: 5.3.29
Released: 1 March 2012
Released: 20 June 2013
Released: 28 August 2014
Alpha 1: 11 June 2015
Planned release: 12 November 2015
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
}
$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);
}
class MySQL implements DB {
public function query($query, ...$params) {
$stmt = $this->pdo->prepare($query);
$stmt->execute($params);
return $stmt;
}
}
var_dump(new class($i) {
public function __construct($i) {
$this->i = $i;
}
});
<?php
declare(strict_types=1);
function add(int $a, int $b): int {
return $a + $b;
}
function foo(): array {
return [];
}
isset($_GET['user']) ? $_GET['user'] : 'nobody'
$_GET['mykey'] ?: ""
$_GET['user'] ?? 'nobody'
$randomStr = random_bytes($length = 16);
$randomInt = random_int($min = 0, $max = 127);
use Doctrine\Common\Collections\Expr\Comparison;
use Doctrine\Common\Collections\Expr\Value;
use Doctrine\Common\Collections\Expr\CompositeExpression;
use Doctrine\Common\Collections\Expr\{ Comparison, Value, CompositeExpression };
intdiv(int $numerator, int $divisor)
HippyVM is an implementation of the PHP language using PyPy technology
Online PHP & HHVM shell, execute code in 100+ different versions!