3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Node { public $child; } function hasCycle($node) { $hare = $node; while ($node->child) { $node = $node->child; $hard = $hard->child->child; if ($node == $hare) { return true; } } return false; } function getLinkedList($length, $cycle = false) { $root = $node = new Node; $cycle_node = null; while ($length--) { $new_node = new Node; $node->child = $new_node; $node = $new_node; if ($cycle && $length == floor($length / 2)) { $cycle_node = $node; } } if ($cycle) { $node->child = $cycle_node; } return $root; } $cycled_list = getLinkedList(100, true); $list = getLinkedList(100, false); var_dump(has_cycle($cycled_list), has_cycle($list));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function has_cycle() in /in/eECgf:51 Stack trace: #0 {main} thrown in /in/eECgf on line 51
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:
53.26 ms | 401 KiB | 8 Q