3v4l.org

run code in 300+ PHP versions simultaneously
<?php $contacts = [/* a few Contact entities in there */]; // ExampleA $names = retrieve_names($contacts); $isPrimaryContact = is_primary_contact($contacts); $countries = retrieve_countries($contacts); // It is easy to provide simple functions: this makes both the calling code easy to read // and each functions, `retrieve_name` and co. easy to implement. // BUT, this comes at a cost: instead of having a O(n) operation you make it a O(3n) because // in each function you would iterate over the array once more. // ExampleB: a more performant alternative. Depending of the logic that needs to be crammed there // it can easily become a lot less readable. $names = []; $isPrimaryContact = false; $countries = []; foreach($contacts as $contact) { $names[] = $contact->name; $isPrimaryContact = $isPrimaryContact || $contact->isPrimary; $countries[] = $contact->address->country; }
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.14, 8.4.16 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Call to undefined function retrieve_names() in /in/fh93m:7 Stack trace: #0 {main} thrown in /in/fh93m on line 7
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
73.29 ms | 991 KiB | 4 Q