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

max() On String And Integer

In PHP 8, the rules of comparison between integers and strings have changed. Hence, max() may return a different value on PHP 7 and PHP 8.

PHP code

<?php

var_dump( max(['', 0]));

?>

Before

string(0) 

After

int(0)

PHP version change

This behavior changed in 8.0.

Extension

© 2023-2026, Damien Seguy - Exakat