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() Emits TypeError

strpos() and stripos() emit a TypeError when the offset is of the wrong type. In PHP 7.4, it emitted a warning.

PHP code

<?php
strpos('a', 'abc', null);
?>

Before

PHP Warning:  strpos() expects parameter 3 to be int, string given

After

PHP Fatal error:  Uncaught TypeError: strpos(): Argument #3 ($offset) must be of type int, string given

PHP version change

This behavior changed in 8.0.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat