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

implode() Arguments Order

It was possible to call implode() with a random order of argument : string first, or array first. PHP would figure out which one to use.

In PHP 8.0, it is now compulsory to put the string in the first place, as the types are checked. Or used named parameters.

PHP code

<?php

print_r(implode([1,2], '3'));

?>

Before

PHP Deprecated:  implode(): Passing glue string after array is deprecated. Swap the parameters 

Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters 
132

After

PHP Fatal error:  Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given 

Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given 

PHP version change

This behavior changed in 8.0.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat