📚 Encyclopedia

Web Development · updated 2026-10-13

PHP 7 to 8 upgrade breakage and other PHP traps

phpphp8migrationpreg-replacepassword-hashlegacy

What broke when the tldr API moved from PHP 7.3 (CentOS 7) to PHP 8.3 (Alma 9), plus a few general PHP traps found later. Most PHP 8 breakage is in code that leaned on silent nulls and loose typing; it shows up as TypeErrors and deprecation warnings, not as obvious failures.

PHP 8 changes that bit

preg_replace eats bcrypt hashes

Writing a password hash into a config file with preg_replace corrupted it: the replacement string $2y$10$... was read as backreferences ($2, $10), so the stored hash lost its prefix and the login was rejected. Insert hashes (or any string containing $) with plain string splicing, str_replace, or preg_replace_callback, and password_verify() the stored value before trusting it.

Running PHP over SSH

Multi-line PHP through ssh host "php -r '...'" is quoting hell (shell, then PHP, then $ variables). Upload a small script, run it, delete it. That was also the pattern on the old CentOS 7 server, which had no Python 3: write a PHP script via SSH, run it with /usr/bin/php, remove it.

php-fpm specifics

php_value in .htaccess is a 500 under php-fpm; set limits in /etc/php.ini. See Setting up an Alma Linux 9 LAMP server.

Small PHP habits that paid off

See also

Linked from

Sources: infra memory (server-setup-gotchas), plumb memory (gotchas), 2026-03 and 2026-10