Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

strpos() Does Not Accept Null As Second Parameter

strpos() and stripos() used to accept NULL as second argument. This was deprecated with a warning, and then removed in PHP 8.

PHP code

<?php

var_dump(strpos('1', null));

?>

Before

strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

After

strpos(): Passing null to parameter #2 ($needle) of type string is deprecated

PHP version change

This behavior was deprecated in 7.3.

This behavior changed in 8.0.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat