43 RFCs
9,054 commits (and counting)
Ubuntu 14.04: PHP 5.5.9, supported to 4/2019
RHEL 7: PHP 5.4.16, supported to 6/2024
$$foo['bar']['baz']
$foo->$bar['baz']
$foo->$bar['baz']()
Foo::$bar['baz']()
$foo()['bar']()
$foo::$bar::$baz
Foo::bar()()
(function() { ... })()
($obj->closure)()
[$obj, 'method']()
$$foo['bar']['baz'];
${$foo['bar']['baz']};
$$foo['bar']['baz'];
($$foo)['bar']['baz'];
$foo->$bar['baz']
$foo->{$bar['baz']}
$foo->$bar['baz']
($foo->$bar)['baz']
Foo::$bar['baz']()
Foo::{$bar['baz']}()
Foo::$bar['baz']()
(Foo::$bar)['baz']()
Foo::$bar['baz']()
Foo::$bar['baz']()
Foo::{$bar['baz']}()
Foo::$bar['baz']()
$method = $bar['baz'];
Foo::$method();
git grep -E '((((::)|(->))\$[a-zA-Z_][a-zA-Z0-9_]*)+\[[^\s]+\]\())|(->\$[a-zA-Z_][a-zA-Z0-9_]*\[)|(\$\$[a-zA-Z_][a-zA-Z0-9_]*\[)'
grep -E '((((::)|(->))\$[a-zA-Z_][a-zA-Z0-9_]*)+\[[^\s]+\]\(\))|(->\$[a-zA-Z_][a-zA-Z0-9_]*\[)|(\$\$[a-zA-Z_][a-zA-Z0-9_]*\[)'
E_ERROR
: 182
E_RECOVERABLE_ERROR
: 17
E_PARSE
: 1
E_ERROR
: 54 (-128)
E_RECOVERABLE_ERROR
: 3 (-14)
E_PARSE
: 0 (-1)
function square(int $n): int {
return $n * $n;
}
square('foo');
Fatal error: Uncaught TypeError:
Argument 1 passed to square() must
be of the type integer, string given
try {
square('foo');
} catch (TypeError $e) {
// Recover gracefully.
// (or show a graceful error)
}
Exception
LogicException
RuntimeException
Throwable
Error
ParseError
TypeError
Exception
LogicException
RuntimeException
try {
...
} catch (Exception $e) {
// Catch almost everything?
}
try {
...
} catch (Throwable $e) {
// Catch everything, but is
// that a good idea?
}
set_exception_handler
try {
$code = '<?php echo 01090; ?>';
highlight_string($code);
} catch (ParseError $e) {
...
}
function log_exc(Exception $e) {
...
}
set_exception_handler('log_exc');
function log_exc(Throwable $e) {
...
}
set_exception_handler('log_exc');
function log_exc($e) {
...
}
set_exception_handler('log_exc');
git grep set_exception_handler
git grep -E 'catch\s*\(\\?Exception\s'
$a = [1];
foreach ($a as &$v) {
if ($v == 1) $a[] = 2;
var_dump($v);
}
int(1)
$a = [1];
foreach ($a as &$v) {
if ($v == 1) $a[] = 2;
var_dump($v);
}
int(1)
int(2)
reset()
key()
current()
end()
next()
prev()
pos()
$a = range(1, 3);
foreach ($a as &$v) {
var_dump(current($a));
}
int(2)
int(3)
bool(false)
$a = range(1, 3);
foreach ($a as &$v) {
var_dump(current($a));
}
int(1)
int(1)
int(1)
array_walk
or array_map
array_walk($a, function (&$v, $k) {
...
});
$a = array_map(function ($v) {
...
}, $a);
git grep -E 'foreach.*\sas\s+&'
function square($n) {
return $n * $n;
}
echo square("0x10");
256
function square($n) {
return $n * $n;
}
echo square("0x10");
0
$n = sscanf('0x10', '%x')[0];
echo square($n);
list()
fails silently with string input
$s = 'abc';
list($a, $b, $c) = $s;
var_dump($a, $b, $c);
string(1) "a"
string(1) "b"
string(1) "c"
$s = 'abc';
list($a, $b, $c) = $s;
var_dump($a, $b, $c);
NULL
NULL
NULL
list($a, $b, $c) = str_split($s);
yield
yield $foo or $bar;
yield ($foo or $bar);
yield $foo or $bar;
(yield $foo) or $bar;
$a = ['o', 'O'];
$opt = SORT_STRING|SORT_FLAG_CASE;
sort($a, $opt);
echo json_encode($a);
["O","o"]
$a = ['o', 'O'];
$opt = SORT_STRING|SORT_FLAG_CASE;
sort($a, $opt);
echo json_encode($a);
["o","O"]
date.timezone
DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
...
bool
int
float
string
null
false
true
resource
object
mixed
numeric
$HTTP_RAW_POST_DATA
file_get_contents('php://input');
ext/mysql
is gone
function f() {
global $$foo->bar;
}
PHP7: Vincent Pontier
Panic: wackystuff (CC-BY-SA 2.0)
Don't panic: Jim Linwood (CC-BY-SA 2.0)
Head in sand: Peter (CC-BY-SA 2.0)
Flag day: Seattle Municipal Archives (CC-BY 2.0)
Dual wield: Joriel Jimenez (CC-BY 2.0)
What do?: Ian Sane (CC-BY 2.0)
Strategy: Horia Varlan (CC-BY 2.0)
The Scream: Edvard Munch (PD)
Sun stone: Michael McCarty (CC-BY 2.0)
Yesterday: Star Trek
Wrenches: LadyDragonflyCC - >;< (CC-BY 2.0)
Soon: k rupp (CC-BY 2.0)