Skip to main content

PHP version changes

Some seemingly basic functions only exist in PHP 8+

Some normally core functions in other languages only exist in new-ish versions of PHP. Here's a list of functions that are actuallynot fairlyavailable newin older versions:

// https://www.php.net/manual/en/function.str-contains.php
str_contains($haystack, $needle); // bool

// https://www.php.net/manual/en/function.str-starts-with.php
str_starts_with($haystack, $needle); // bool

// https://www.php.net/manual/en/function.str-ends-with.php
str_ends_with($haystack, $needle); // bool

// https://www.php.net/manual/en/function.fdiv
fdiv($num1, $num2); // float, INF, -INF, or NAN 

// https://www.php.net/manual/en/function.get-debug-type
// Returns useful data instead of just "Object", compared to PHP,gettype().
evenget_debug_type($value); though// itstring
seems

Error bizarre.reporting

defaults

Forare instance,different str_contains is only available fromin PHP 8

onwards,

The default settings for which canerrors catchare reported have changed:

; old default (PHP versions before 8)
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

; new default (PHP 8 onwards)
error_reporting = E_ALL

When upgrading, you offmight guardtherefore ifsee a lot more errors and warnings in your logs than you arewould using servers that still use PHP 7 for some reason.expect.