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 git.master, git.master_jit
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.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
58.24 ms | 991 KiB | 4 Q