3v4l.org

run code in 300+ PHP versions simultaneously
<?php $null = null; // Fatal error: var_export($null->someMethod() ?? null); //echo "\n---\n"; // Fatal error: var_export($null->someMethod()->city ?? null); //echo "\n---\n"; // Fatal error: var_export($null->someMethod()?->city ?? null); //echo "\n---\n"; var_export($null?->someMethod() ?? "null coalesced"); // ^-- null-safe operator required before method call echo "\n---\n"; var_export($null?->property?->someMethod() ?? "null coalesced"); // ^----------^-- null-safe operators required before method call echo "\n---\n"; var_export($null->property->anotherProperty ?? "null coalesced"); // ^---------^-- NO METHODS CALLED, SO NO NULL-SAFE OPERATORS REQUIRED echo "\n---\n"; var_export($null?->property?->someMethod()->anotherProperty ?? "null coalesced"); // ^ ^ ^-- NO NULL-SAFE OPERATORS REQUIRED IF NO SUBSEQUENT METHODS CALLED // |----------|-- nulls-safe operators required before method call
Output for git.master, git.master_jit, rfc.property-hooks
'null coalesced' --- 'null coalesced' --- 'null coalesced' --- 'null coalesced'

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:
78.78 ms | 405 KiB | 5 Q