PHP 5.5: Major Features
PHP 5.5 makes memory-friendly iteration mainstream with generators (yield), adds finally to try/catch, introduces a proper password API (password_hash, password_verify, password_needs_rehash), and adds everyday helpers like array_column() and the ClassName::class constant. It also ships Zend OPcache (when built/enabled), which changes performance characteristics of production workloads. Migration work often focuses on subtle foreach/list() behavior and finishing mysql → mysqli/PDO moves.
Anchor your checklist to migration55.
Table of Contents
- Generators (
yield) finally- Password hashing API
array_column()&::class- OPcache
- Practical recipes
- Backward incompatible changes
- Deprecated
- Other notes
Generators (yield)
Generators compute values on demand instead of building giant arrays:
function lines($path)
{
$fh = fopen($path, 'rb');
try {
while (($line = fgets($fh)) !== false) {
yield rtrim($line, "\r\n");
}
} finally {
fclose($fh);
}
}
Use for large CSV/LOG streaming and cooperative iterators.
finally
Runs always after try/catch—ideal for closing resources even when return or exceptions occur.
Password hashing API
$hash = password_hash($plain, PASSWORD_DEFAULT);
if (password_verify($plain, $hash)) {
if (password_needs_rehash($hash, PASSWORD_DEFAULT)) {
$hash = password_hash($plain, PASSWORD_DEFAULT);
}
}
Stop hand-rolling salt and cost unless you must interoperate with legacy schemes.
array_column() & ::class
array_column($rows, 'email', 'id')extracts columns from result sets.SomeClass::classresolves to the fully qualified class name string—refactor-safe vs string literals.
OPcache
When enabled, OPcache caches bytecode—after deploys, coordinate opcache_reset() or process reloads so changes apply predictably.
Practical recipes
Iterator vs array
Replace file() on huge files with yield-based line readers to cap memory.
Password migration
On login, password_verify against old hashes; if OK and password_needs_rehash, re-save with PASSWORD_DEFAULT.
Backward incompatible changes
Notable (full list: migration55 incompatible):
foreachwith internal array pointers and by-reference iteration—edge cases changed; regression-test code that mutates the array being iterated.list()insideforeach—ordering/assignment semantics for nested lists were tightened; verify templates that unpack nested arrays.GD,intl,openssland other extensions: method signatures and error modes—consult per-function notes if you wrap them.::classas a keyword context—ensure you did not useclassas a constant name without quoting in ancient code.
Deprecated
mysqlextension—mysqli/PDO only path forward.preg_replace()/emodifier—dangerous; usepreg_replace_callback().
Other notes
empty()on expressions—behavior expanded; auditempty($x->y)patterns.Password hashingcost defaults evolve over PHP versions—plan periodic rehash on login.
Closing thoughts
PHP 5.5 is the “async-friendly memory + crypto hygiene” release before syntax sugar in 5.6: master generators and password_*, close mysql, then variadics and ** in 5.6 feel like a natural next step.