PHP 8 Compatibility
-
I’m just going over a WordPress based site updating for PHP 8.1. I found a couple of calls to ltrim() in the redirect function that produce a deprecation error.
Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated ...
I found a solution to that by casting the values as string before attempting to trim them:
$base = ltrim((string) $base, '/'); $uri = ltrim((string) $uri, '/');
Originally it was
$base = ltrim($base, '/'); $uri = ltrim($uri, '/');
There may be a better ways of achieving the same result.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘PHP 8 Compatibility’ is closed to new replies.